|
7 | 7 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
8 | 8 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
9 | 9 | import static org.mockito.ArgumentMatchers.any;
|
10 |
| -import static org.mockito.ArgumentMatchers.eq; |
11 | 10 | import static org.mockito.Mockito.mock;
|
12 | 11 | import static org.mockito.Mockito.times;
|
13 | 12 | import static org.mockito.Mockito.verify;
|
|
47 | 46 | import io.airbyte.config.secrets.JsonSecretsProcessor;
|
48 | 47 | import io.airbyte.data.helpers.ActorDefinitionVersionUpdater;
|
49 | 48 | import io.airbyte.data.services.DestinationService;
|
50 |
| -import io.airbyte.featureflag.DeleteSecretsWhenTombstoneActors; |
51 | 49 | import io.airbyte.featureflag.TestClient;
|
52 | 50 | import io.airbyte.featureflag.Workspace;
|
53 | 51 | import io.airbyte.persistence.job.factory.OAuthConfigSupplier;
|
@@ -337,57 +335,6 @@ void testListDestinationForWorkspace() throws JsonValidationException, ConfigNot
|
337 | 335 | .prepareSecretsForOutput(destinationConnection.getConfiguration(), destinationDefinitionSpecificationRead.getConnectionSpecification());
|
338 | 336 | }
|
339 | 337 |
|
340 |
| - @Test |
341 |
| - void testDeleteDestination() |
342 |
| - throws JsonValidationException, ConfigNotFoundException, IOException, io.airbyte.data.exceptions.ConfigNotFoundException { |
343 |
| - final JsonNode newConfiguration = destinationConnection.getConfiguration(); |
344 |
| - ((ObjectNode) newConfiguration).put("apiKey", "987-xyz"); |
345 |
| - |
346 |
| - final DestinationConnection expectedSourceConnection = Jsons.clone(destinationConnection).withTombstone(true); |
347 |
| - |
348 |
| - final DestinationIdRequestBody destinationIdRequestBody = new DestinationIdRequestBody().destinationId(destinationConnection.getDestinationId()); |
349 |
| - final StandardSync standardSync = ConnectionHelpers.generateSyncWithDestinationId(destinationConnection.getDestinationId()); |
350 |
| - standardSync.setBreakingChange(false); |
351 |
| - final ConnectionRead connectionRead = ConnectionHelpers.generateExpectedConnectionRead(standardSync); |
352 |
| - final ConnectionReadList connectionReadList = new ConnectionReadList().connections(Collections.singletonList(connectionRead)); |
353 |
| - final WorkspaceIdRequestBody workspaceIdRequestBody = new WorkspaceIdRequestBody().workspaceId(destinationConnection.getWorkspaceId()); |
354 |
| - |
355 |
| - when(configRepository.getDestinationConnection(destinationConnection.getDestinationId())) |
356 |
| - .thenReturn(destinationConnection) |
357 |
| - .thenReturn(expectedSourceConnection); |
358 |
| - when(destinationService.getDestinationConnectionWithSecrets(destinationConnection.getDestinationId())) |
359 |
| - .thenReturn(destinationConnection) |
360 |
| - .thenReturn(expectedSourceConnection); |
361 |
| - when(oAuthConfigSupplier.maskSourceOAuthParameters(destinationDefinitionSpecificationRead.getDestinationDefinitionId(), |
362 |
| - destinationConnection.getWorkspaceId(), |
363 |
| - newConfiguration, destinationDefinitionVersion.getSpec())).thenReturn(newConfiguration); |
364 |
| - when(configRepository.getStandardDestinationDefinition(destinationDefinitionSpecificationRead.getDestinationDefinitionId())) |
365 |
| - .thenReturn(standardDestinationDefinition); |
366 |
| - when(actorDefinitionVersionHelper.getDestinationVersion(standardDestinationDefinition, destinationConnection.getWorkspaceId(), |
367 |
| - destinationConnection.getDestinationId())) |
368 |
| - .thenReturn(destinationDefinitionVersion); |
369 |
| - when(configRepository.getDestinationDefinitionFromDestination(destinationConnection.getDestinationId())) |
370 |
| - .thenReturn(standardDestinationDefinition); |
371 |
| - when(connectionsHandler.listConnectionsForWorkspace(workspaceIdRequestBody)).thenReturn(connectionReadList); |
372 |
| - when( |
373 |
| - secretsProcessor.prepareSecretsForOutput(destinationConnection.getConfiguration(), |
374 |
| - destinationDefinitionSpecificationRead.getConnectionSpecification())) |
375 |
| - .thenReturn(destinationConnection.getConfiguration()); |
376 |
| - when(actorDefinitionVersionHelper.getDestinationVersionWithOverrideStatus(standardDestinationDefinition, destinationConnection.getWorkspaceId(), |
377 |
| - destinationConnection.getDestinationId())).thenReturn(destinationDefinitionVersionWithOverrideStatus); |
378 |
| - // By default feature flag is false |
379 |
| - when(featureFlagClient.boolVariation( |
380 |
| - eq(DeleteSecretsWhenTombstoneActors.INSTANCE), |
381 |
| - any(Workspace.class))).thenReturn(false); |
382 |
| - |
383 |
| - destinationHandler.deleteDestination(destinationIdRequestBody); |
384 |
| - |
385 |
| - verify(destinationService).getDestinationConnectionWithSecrets(any()); |
386 |
| - verify(destinationService).writeDestinationConnectionWithSecrets(any(), any()); |
387 |
| - verify(connectionsHandler).listConnectionsForWorkspace(workspaceIdRequestBody); |
388 |
| - verify(connectionsHandler).deleteConnection(connectionRead.getConnectionId()); |
389 |
| - } |
390 |
| - |
391 | 338 | @Test
|
392 | 339 | void testDeleteDestinationAndDeleteSecrets()
|
393 | 340 | throws JsonValidationException, ConfigNotFoundException, IOException, io.airbyte.data.exceptions.ConfigNotFoundException {
|
@@ -426,14 +373,10 @@ void testDeleteDestinationAndDeleteSecrets()
|
426 | 373 | .thenReturn(destinationConnection.getConfiguration());
|
427 | 374 | when(actorDefinitionVersionHelper.getDestinationVersionWithOverrideStatus(standardDestinationDefinition, destinationConnection.getWorkspaceId(),
|
428 | 375 | destinationConnection.getDestinationId())).thenReturn(destinationDefinitionVersionWithOverrideStatus);
|
429 |
| - // Turn on feature flag to delete secrets |
430 |
| - when(featureFlagClient.boolVariation( |
431 |
| - eq(DeleteSecretsWhenTombstoneActors.INSTANCE), |
432 |
| - any(Workspace.class))).thenReturn(true); |
433 | 376 | destinationHandler.deleteDestination(destinationIdRequestBody);
|
434 | 377 |
|
435 |
| - // With the flag on, we should not no longer get secrets or write secrets anymore (since we are |
436 |
| - // deleting the destination). |
| 378 | + // We should not no longer get secrets or write secrets anymore (since we are deleting the |
| 379 | + // destination). |
437 | 380 | verify(destinationService, times(0)).writeDestinationConnectionWithSecrets(expectedSourceConnection, connectorSpecification);
|
438 | 381 | verify(destinationService, times(0)).getDestinationConnectionWithSecrets(any());
|
439 | 382 | verify(destinationService).tombstoneDestination(any(), any(), any(), any());
|
|
0 commit comments