@Test public void shouldVerifyUserPropertiesOverrideConfiguredProperties() { final EncryptionComponent encryptionComponent = mock(EncryptionComponent.class); final Verifier verifier = new Verifier() { @Override public List<Result> verify(String connectorId, Map<String, String> parameters) { assertThat(parameters).containsEntry("configuredProperty","val2"); return null; } }; final ConnectorHandler connectorHandler = new ConnectorHandler(dataManager, verifier , NO_CREDENTIALS, NO_INSPECTORS, NO_STATE, encryptionComponent, applicationContext, NO_ICON_DAO, NO_EXTENSION_DATA_MANAGER, NO_METADATA_CONFIGURATION_PROPERTIES); final Connector connector = new Connector.Builder() .id("connectorId") .putConfiguredProperty("configuredProperty","val1") .build(); when(dataManager.fetch(Connector.class,"connectorId")).thenReturn(connector); when(dataManager.fetchAll(Integration.class)).thenReturn(() -> 0); Map<String, String> mutableMapParams = new HashMap<>(10); mutableMapParams.put("configuredProperty", "val2"); when(encryptionComponent.decrypt(anyMap())).then(AdditionalAnswers.returnsFirstArg()); connectorHandler.verifyConnectionParameters("connectorId", mutableMapParams); }
@POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Path("/{id}/verifier") public List<Verifier.Result> verifyConnectionParameters(@NotNull @PathParam("id") final String connectorId, final Map<String, String> props) { final Connector connector = get(connectorId); Map<String, String> verifierProperties = new HashMap<>(); verifierProperties.putAll(connector.getConfiguredProperties()); verifierProperties.putAll(props); return verifier.verify(connectorId, encryptionComponent.decrypt(verifierProperties)); }
ConnectorHandler extends BaseHandler implements Getter<Connector>, Updater<Connector>, Deleter<Connector> { @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Path("/{id}/verifier") public List<Verifier.Result> verifyConnectionParameters(@NotNull @PathParam("id") final String connectorId, final Map<String, String> props) { final Connector connector = get(connectorId); Map<String, String> verifierProperties = new HashMap<>(); verifierProperties.putAll(connector.getConfiguredProperties()); verifierProperties.putAll(props); return verifier.verify(connectorId, encryptionComponent.decrypt(verifierProperties)); } }
ConnectorHandler extends BaseHandler implements Getter<Connector>, Updater<Connector>, Deleter<Connector> { @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Path("/{id}/verifier") public List<Verifier.Result> verifyConnectionParameters(@NotNull @PathParam("id") final String connectorId, final Map<String, String> props) { final Connector connector = get(connectorId); Map<String, String> verifierProperties = new HashMap<>(); verifierProperties.putAll(connector.getConfiguredProperties()); verifierProperties.putAll(props); return verifier.verify(connectorId, encryptionComponent.decrypt(verifierProperties)); } @SuppressWarnings("PMD.ExcessiveParameterList") @Autowired  ConnectorHandler(final DataManager dataMgr, final Verifier verifier, final Credentials credentials, final Inspectors inspectors,
                            final ClientSideState state, final EncryptionComponent encryptionComponent, final ApplicationContext applicationContext,
                            final IconDao iconDao, final FileDataManager extensionDataManager, final MetadataConfigurationProperties config); @SuppressWarnings("PMD.ExcessiveParameterList")  ConnectorHandler(final DataManager dataMgr, final Verifier verifier, final Credentials credentials, final Inspectors inspectors,
                            final ClientSideState state, final EncryptionComponent encryptionComponent, final ApplicationContext applicationContext,
                            final IconDao iconDao, final FileDataManager extensionDataManager, final ConnectorPropertiesHandler propertiesHandler); }
ConnectorHandler extends BaseHandler implements Getter<Connector>, Updater<Connector>, Deleter<Connector> { @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Path("/{id}/verifier") public List<Verifier.Result> verifyConnectionParameters(@NotNull @PathParam("id") final String connectorId, final Map<String, String> props) { final Connector connector = get(connectorId); Map<String, String> verifierProperties = new HashMap<>(); verifierProperties.putAll(connector.getConfiguredProperties()); verifierProperties.putAll(props); return verifier.verify(connectorId, encryptionComponent.decrypt(verifierProperties)); } @SuppressWarnings("PMD.ExcessiveParameterList") @Autowired  ConnectorHandler(final DataManager dataMgr, final Verifier verifier, final Credentials credentials, final Inspectors inspectors,
                            final ClientSideState state, final EncryptionComponent encryptionComponent, final ApplicationContext applicationContext,
                            final IconDao iconDao, final FileDataManager extensionDataManager, final MetadataConfigurationProperties config); @SuppressWarnings("PMD.ExcessiveParameterList")  ConnectorHandler(final DataManager dataMgr, final Verifier verifier, final Credentials credentials, final Inspectors inspectors,
                            final ClientSideState state, final EncryptionComponent encryptionComponent, final ApplicationContext applicationContext,
                            final IconDao iconDao, final FileDataManager extensionDataManager, final ConnectorPropertiesHandler propertiesHandler); @Path("/{id}/credentials") ConnectorCredentialHandler credentials(@NotNull final @PathParam("id") String connectorId); @Path("/custom") CustomConnectorHandler customConnectorHandler(); @Override void delete(final String id); @Override Connector get(final String id); @Path("/{connectorId}/actions") ConnectorActionHandler getActions(@PathParam("connectorId") final String connectorId); @Path("/{id}/icon") ConnectorIconHandler getConnectorIcon(@NotNull @PathParam("id") final String connectorId); @Path("/{id}/properties") ConnectorPropertiesHandler properties(); @GET @Produces(MediaType.APPLICATION_JSON) @Path(value = "/{id}/actions/{actionId}/filters/options") FilterOptions getFilterOptions(@PathParam("id") @Parameter(required = true) final String connectorId,
                                          @PathParam("actionId") @Parameter(required = true) final String actionId); @GET @Produces(MediaType.APPLICATION_JSON) ListResult<Connector> list(
        @Parameter(required = false, description = "Filter by connector's name")
        @QueryParam("name") String name,
        @Parameter(required = false, description = "Filter by connector's group id")
        @QueryParam("connectorGroupId") String connectorGroupId,
        @Parameter(required = false, description = "Page number to return")
        @QueryParam("page") @DefaultValue("1") int page,
        @Parameter(required = false, description = "Number of records per page")
        @QueryParam("per_page") @DefaultValue("20") int perPage
    ); @GET @Path("/apiConnectors") @Produces(MediaType.APPLICATION_JSON) ListResult<Connector> listApiConnectors(
        @Parameter(required = true, description = "Filter by matching connector group ids")
        @QueryParam("connectorGroupIdList") List<String> connectorGroupIdList,
        @Parameter(required = false, description = "Page number to return")
        @QueryParam("page") @DefaultValue("1") int page,
        @Parameter(required = false, description = "Number of records per page")
        @QueryParam("per_page") @DefaultValue("20") int perPage); @Override Kind resourceKind(); @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Path("/{id}/verifier") List<Verifier.Result> verifyConnectionParameters(@NotNull @PathParam("id") final String connectorId, final Map<String, String> props); @PUT @Path(value = "/{id}") @Consumes(MediaType.MULTIPART_FORM_DATA) void update(@MultipartForm ConnectorFormData connectorFormData); }
ConnectorHandler extends BaseHandler implements Getter<Connector>, Updater<Connector>, Deleter<Connector> { @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Path("/{id}/verifier") public List<Verifier.Result> verifyConnectionParameters(@NotNull @PathParam("id") final String connectorId, final Map<String, String> props) { final Connector connector = get(connectorId); Map<String, String> verifierProperties = new HashMap<>(); verifierProperties.putAll(connector.getConfiguredProperties()); verifierProperties.putAll(props); return verifier.verify(connectorId, encryptionComponent.decrypt(verifierProperties)); } @SuppressWarnings("PMD.ExcessiveParameterList") @Autowired  ConnectorHandler(final DataManager dataMgr, final Verifier verifier, final Credentials credentials, final Inspectors inspectors,
                            final ClientSideState state, final EncryptionComponent encryptionComponent, final ApplicationContext applicationContext,
                            final IconDao iconDao, final FileDataManager extensionDataManager, final MetadataConfigurationProperties config); @SuppressWarnings("PMD.ExcessiveParameterList")  ConnectorHandler(final DataManager dataMgr, final Verifier verifier, final Credentials credentials, final Inspectors inspectors,
                            final ClientSideState state, final EncryptionComponent encryptionComponent, final ApplicationContext applicationContext,
                            final IconDao iconDao, final FileDataManager extensionDataManager, final ConnectorPropertiesHandler propertiesHandler); @Path("/{id}/credentials") ConnectorCredentialHandler credentials(@NotNull final @PathParam("id") String connectorId); @Path("/custom") CustomConnectorHandler customConnectorHandler(); @Override void delete(final String id); @Override Connector get(final String id); @Path("/{connectorId}/actions") ConnectorActionHandler getActions(@PathParam("connectorId") final String connectorId); @Path("/{id}/icon") ConnectorIconHandler getConnectorIcon(@NotNull @PathParam("id") final String connectorId); @Path("/{id}/properties") ConnectorPropertiesHandler properties(); @GET @Produces(MediaType.APPLICATION_JSON) @Path(value = "/{id}/actions/{actionId}/filters/options") FilterOptions getFilterOptions(@PathParam("id") @Parameter(required = true) final String connectorId,
                                          @PathParam("actionId") @Parameter(required = true) final String actionId); @GET @Produces(MediaType.APPLICATION_JSON) ListResult<Connector> list(
        @Parameter(required = false, description = "Filter by connector's name")
        @QueryParam("name") String name,
        @Parameter(required = false, description = "Filter by connector's group id")
        @QueryParam("connectorGroupId") String connectorGroupId,
        @Parameter(required = false, description = "Page number to return")
        @QueryParam("page") @DefaultValue("1") int page,
        @Parameter(required = false, description = "Number of records per page")
        @QueryParam("per_page") @DefaultValue("20") int perPage
    ); @GET @Path("/apiConnectors") @Produces(MediaType.APPLICATION_JSON) ListResult<Connector> listApiConnectors(
        @Parameter(required = true, description = "Filter by matching connector group ids")
        @QueryParam("connectorGroupIdList") List<String> connectorGroupIdList,
        @Parameter(required = false, description = "Page number to return")
        @QueryParam("page") @DefaultValue("1") int page,
        @Parameter(required = false, description = "Number of records per page")
        @QueryParam("per_page") @DefaultValue("20") int perPage); @Override Kind resourceKind(); @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Path("/{id}/verifier") List<Verifier.Result> verifyConnectionParameters(@NotNull @PathParam("id") final String connectorId, final Map<String, String> props); @PUT @Path(value = "/{id}") @Consumes(MediaType.MULTIPART_FORM_DATA) void update(@MultipartForm ConnectorFormData connectorFormData);  }