use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ManagerSyncServiceTest method testNotifyBridgeStatusChange.
@Test
public void testNotifyBridgeStatusChange() throws InterruptedException {
BridgeDTO dto = new BridgeDTO("myId-1", "myName-1", "myEndpoint", "myCustomerId", ManagedResourceStatus.PROVISIONING, TestSupport.KAFKA_CONNECTION_DTO);
stubBridgeUpdate();
String expectedJsonUpdate = "{\"id\": \"myId-1\", \"name\": \"myName-1\", \"endpoint\": \"myEndpoint\", \"customerId\": \"myCustomerId\", \"status\": \"provisioning\"}";
// One update to the manager is expected
CountDownLatch latch = new CountDownLatch(1);
addBridgeUpdateRequestListener(latch);
managerSyncService.notifyBridgeStatusChange(dto).await().atMost(Duration.ofSeconds(5));
assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue();
wireMockServer.verify(putRequestedFor(urlEqualTo(APIConstants.SHARD_API_BASE_PATH)).withRequestBody(equalToJson(expectedJsonUpdate, true, true)).withHeader("Content-Type", equalTo("application/json")));
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeIngressServiceTest method testBridgeIngressRedeployment.
@Test
public void testBridgeIngressRedeployment() {
// Given
BridgeDTO dto = TestSupport.newProvisioningBridgeDTO();
String patchedCustomerId = TestSupport.CUSTOMER_ID + "-patched";
// When
bridgeIngressService.createBridgeIngress(dto);
dto.setCustomerId(patchedCustomerId);
bridgeIngressService.createBridgeIngress(dto);
// Then
BridgeIngress bridgeIngress = fetchBridgeIngress(dto);
assertThat(bridgeIngress).isNotNull();
assertThat(bridgeIngress.getSpec().getCustomerId()).isEqualTo(patchedCustomerId);
Secret secret = fetchBridgeIngressSecret(dto);
assertThat(secret).isNotNull();
assertThat(secret.getMetadata().getName()).isEqualTo(bridgeIngress.getMetadata().getName());
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeIngressServiceTest method testBridgeIngressDeletionRemovesAllLinkedResource.
@Test
@Disabled("Delete loop in BridgeIngressController does not get called. Bug in the SDK? https://issues.redhat.com/browse/MGDOBR-128")
public void testBridgeIngressDeletionRemovesAllLinkedResource() {
// Given
BridgeDTO dto = TestSupport.newProvisioningBridgeDTO();
// When
bridgeIngressService.createBridgeIngress(dto);
Awaitility.await().atMost(Duration.ofMinutes(2)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> {
Deployment deployment = fetchBridgeIngressDeployment(dto);
assertThat(deployment).isNotNull();
});
bridgeIngressService.deleteBridgeIngress(dto);
// Then
Awaitility.await().atMost(Duration.ofMinutes(2)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> {
Deployment deployment = fetchBridgeIngressDeployment(dto);
assertThat(deployment).isNull();
});
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method getProcessorsWithSendToBridgeAction.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void getProcessorsWithSendToBridgeAction() {
BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
String bridgeId = bridgeResponse.getId();
BridgeDTO bridge = new BridgeDTO(bridgeId, bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, TestConstants.DEFAULT_CUSTOMER_ID, ManagedResourceStatus.READY, new KafkaConnectionDTO());
Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
BaseAction action = TestUtils.createSendToBridgeAction(bridgeId);
TestUtils.updateBridge(bridge);
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(TestConstants.DEFAULT_PROCESSOR_NAME, filters, null, action));
List<ProcessorDTO> processors = TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
});
assertThat(processors.size()).isEqualTo(1);
ProcessorDTO processor = processors.get(0);
assertThat(processor.getName()).isEqualTo(TestConstants.DEFAULT_PROCESSOR_NAME);
assertThat(processor.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
assertThat(processor.getDefinition().getFilters().size()).isEqualTo(1);
assertThat(processor.getDefinition().getRequestedAction()).isNotNull();
assertThat(processor.getDefinition().getRequestedAction().getType()).isEqualTo(SendToBridgeAction.TYPE);
assertThat(processor.getDefinition().getRequestedAction().getParameters()).containsEntry(SendToBridgeAction.BRIDGE_ID_PARAM, bridgeId);
assertThat(processor.getDefinition().getResolvedAction()).isNotNull();
assertThat(processor.getDefinition().getResolvedAction().getType()).isEqualTo(WebhookAction.TYPE);
assertThat(processor.getDefinition().getResolvedAction().getParameters()).containsEntry(WebhookAction.ENDPOINT_PARAM, TEST_BRIDGE_WEBHOOK);
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method testUnouthorizedRole.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testUnouthorizedRole() {
reset(jwt);
when(jwt.getClaim(APIConstants.SUBJECT_ATTRIBUTE_CLAIM)).thenReturn("hacker");
TestUtils.getBridgesToDeployOrDelete().then().statusCode(403);
TestUtils.getProcessorsToDeployOrDelete().then().statusCode(403);
TestUtils.updateBridge(new BridgeDTO()).then().statusCode(403);
TestUtils.updateProcessor(new ProcessorDTO()).then().statusCode(403);
}
Aggregations