use of io.syndesis.common.model.connection.Connection in project syndesis by syndesisio.
the class WebhookCustomizerTest method testOpenApiCustomizer.
@Test
public void testOpenApiCustomizer() throws Exception {
TestResourceManager manager = new TestResourceManager();
Connector connector;
ConnectorAction webhookIncomingAction;
try (InputStream is = WebhookCustomizerTest.class.getResourceAsStream("/META-INF/syndesis/connector/webhook.json")) {
connector = JsonUtils.readFromStream(is, Connector.class);
webhookIncomingAction = connector.getActions(ConnectorAction.class).stream().filter(a -> a.getId().get().equals("io.syndesis:webhook-incoming")).findFirst().orElseThrow(IllegalArgumentException::new);
}
webhookIncomingAction = webhookIncomingAction.builder().descriptor(new ConnectorDescriptor.Builder().connectorId("webhook").build()).build();
Integration integration = manager.newIntegration(new Step.Builder().stepKind(StepKind.endpoint).putConfiguredProperty("contextPath", "token").action(webhookIncomingAction).connection(new Connection.Builder().connector(connector).build()).build());
IntegrationDeployment deployment = new IntegrationDeployment.Builder().userId("user").id("idId").spec(integration).build();
CamelKIntegrationCustomizer customizer = new WebhookCustomizer();
io.syndesis.server.controller.integration.camelk.crd.Integration i = customizer.customize(deployment, new io.syndesis.server.controller.integration.camelk.crd.Integration(), EnumSet.of(Exposure.SERVICE));
assertThat(i.getSpec().getConfiguration()).hasSize(1);
assertThat(i.getSpec().getConfiguration()).anyMatch(c -> Objects.equals("customizer.platform-http.path=/webhook/", c.getValue()) && Objects.equals("property", c.getType()));
}
use of io.syndesis.common.model.connection.Connection in project syndesis by syndesisio.
the class ApplicatorTest method shouldNotApplyNullOrEmptyPropertyValues.
@Test
public void shouldNotApplyNullOrEmptyPropertyValues() {
final Connection.Builder connection = new Connection.Builder();
Applicator.applyProperty(connection, "emptyProperty", "");
Applicator.applyProperty(connection, "nullProperty", "");
final Connection built = connection.build();
assertThat(built.getConfiguredProperties()).isEmpty();
}
use of io.syndesis.common.model.connection.Connection in project syndesis by syndesisio.
the class OAuth1ApplicatorTest method shouldApplyTokens.
@Test
public void shouldApplyTokens() {
final SocialProperties properties = new SocialProperties() {
};
properties.setAppId("appId");
properties.setAppSecret("appSecret");
final OAuth1Applicator applicator = new OAuth1Applicator(properties);
applicator.setAccessTokenSecretProperty("accessTokenSecretProperty");
applicator.setAccessTokenValueProperty("accessTokenValueProperty");
applicator.setConsumerKeyProperty("consumerKeyProperty");
applicator.setConsumerSecretProperty("consumerSecretProperty");
final Connection connection = new Connection.Builder().build();
final Connection result = applicator.applyTo(connection, new OAuthToken("tokenValue", "tokenSecret"));
final Connection expected = new Connection.Builder().putConfiguredProperty("accessTokenSecretProperty", "tokenSecret").putConfiguredProperty("accessTokenValueProperty", "tokenValue").putConfiguredProperty("consumerKeyProperty", "appId").putConfiguredProperty("consumerSecretProperty", "appSecret").build();
assertThat(result).isEqualToIgnoringGivenFields(expected, "lastUpdated");
assertThat(result.getLastUpdated()).isPresent();
}
use of io.syndesis.common.model.connection.Connection in project syndesis by syndesisio.
the class CredentialsTest method shouldApplyReceivedCredentialsToConnections.
@Test
public void shouldApplyReceivedCredentialsToConnections() {
final CredentialProvider credentialProvider = mock(CredentialProvider.class);
when(locator.providerWithId("providerId")).thenReturn(credentialProvider);
final CredentialFlowState flowState = new OAuth2CredentialFlowState.Builder().providerId("providerId").returnUrl(URI.create("/ui#state")).code("code").state("state").build();
final Connection connection = new Connection.Builder().connector(new Connector.Builder().putProperty("key", new ConfigurationProperty.Builder().build()).build()).build();
when(credentialProvider.applyTo(new Connection.Builder().createFrom(connection).isDerived(true).build(), flowState)).then(a -> new Connection.Builder().createFrom(a.getArgument(0)).putConfiguredProperty("key", "value").build());
final Connection finishedConnection = credentials.apply(connection, flowState);
assertThat(finishedConnection).isNotNull();
assertThat(finishedConnection.getConfiguredProperties()).contains(entry("key", "value"));
assertThat(finishedConnection.isDerived()).isTrue();
}
use of io.syndesis.common.model.connection.Connection in project syndesis by syndesisio.
the class OAuth2Applicator method applyTo.
/**
* Default implementation that applies {@link SocialProperties} and
* {@link AccessGrant} to {@link Connection.Builder}.
*/
@Override
public final Connection applyTo(final Connection connection, final AccessGrant accessGrant) {
final Connection.Builder mutableConnection = new Connection.Builder().createFrom(connection).lastUpdated(new Date());
Applicator.applyProperty(mutableConnection, clientIdProperty, socialProperties.getAppId());
Applicator.applyProperty(mutableConnection, clientSecretProperty, socialProperties.getAppSecret());
Applicator.applyProperty(mutableConnection, accessTokenProperty, accessGrant.getAccessToken());
Applicator.applyProperty(mutableConnection, refreshTokenProperty, accessGrant.getRefreshToken());
final Long expireTime = accessGrant.getExpireTime();
Applicator.applyProperty(mutableConnection, accessTokenExpiresAtProperty, expireTime == null ? null : expireTime.toString());
additionalApplication(mutableConnection, accessGrant);
return mutableConnection.build();
}
Aggregations