|
1 | 1 | package net.snowflake.client.core.auth.wif; |
2 | 2 |
|
3 | 3 | import static net.snowflake.client.core.auth.wif.WorkloadIdentityProviderType.AWS; |
4 | | -import static net.snowflake.client.core.auth.wif.WorkloadIdentityProviderType.AZURE; |
5 | | -import static net.snowflake.client.core.auth.wif.WorkloadIdentityProviderType.GCP; |
6 | | -import static net.snowflake.client.core.auth.wif.WorkloadIdentityProviderType.OIDC; |
7 | 4 |
|
8 | 5 | import java.util.HashMap; |
9 | 6 | import net.snowflake.client.core.SFException; |
@@ -53,72 +50,4 @@ public void shouldCreateProperAttestationCreatorByType() throws SFException { |
53 | 50 | Assertions.assertThrows( |
54 | 51 | SFException.class, () -> provider.getCreator("UNKNOWN_IDENTITY_PROVIDER")); |
55 | 52 | } |
56 | | - |
57 | | - @Test |
58 | | - public void shouldAutodetectAwsProvider() throws SFException { |
59 | | - WorkloadIdentityAttestationProvider provider = createMockProvider(AWS); |
60 | | - WorkloadIdentityAttestation attestation = provider.getAttestation(null); |
61 | | - |
62 | | - Assertions.assertNotNull(attestation); |
63 | | - Assertions.assertEquals(AWS, attestation.getProvider()); |
64 | | - Assertions.assertEquals("aws_cred", attestation.getCredential()); |
65 | | - } |
66 | | - |
67 | | - @Test |
68 | | - public void shouldAutodetectGCPProvider() throws SFException { |
69 | | - WorkloadIdentityAttestationProvider provider = createMockProvider(GCP); |
70 | | - WorkloadIdentityAttestation attestation = provider.getAttestation(null); |
71 | | - |
72 | | - Assertions.assertNotNull(attestation); |
73 | | - Assertions.assertEquals(WorkloadIdentityProviderType.GCP, attestation.getProvider()); |
74 | | - Assertions.assertEquals("gcp_cred", attestation.getCredential()); |
75 | | - } |
76 | | - |
77 | | - @Test |
78 | | - public void shouldAutodetectAzureProvider() throws SFException { |
79 | | - WorkloadIdentityAttestationProvider provider = createMockProvider(AZURE); |
80 | | - WorkloadIdentityAttestation attestation = provider.getAttestation(null); |
81 | | - |
82 | | - Assertions.assertNotNull(attestation); |
83 | | - Assertions.assertEquals(WorkloadIdentityProviderType.AZURE, attestation.getProvider()); |
84 | | - Assertions.assertEquals("azure_cred", attestation.getCredential()); |
85 | | - } |
86 | | - |
87 | | - @Test |
88 | | - public void shouldAutodetectOidcProvider() throws SFException { |
89 | | - WorkloadIdentityAttestationProvider provider = createMockProvider(OIDC); |
90 | | - WorkloadIdentityAttestation attestation = provider.getAttestation(null); |
91 | | - Assertions.assertNotNull(attestation); |
92 | | - Assertions.assertEquals(WorkloadIdentityProviderType.OIDC, attestation.getProvider()); |
93 | | - Assertions.assertEquals("oidc_cred", attestation.getCredential()); |
94 | | - } |
95 | | - |
96 | | - WorkloadIdentityAttestationProvider createMockProvider( |
97 | | - WorkloadIdentityProviderType actualPresentType) { |
98 | | - AwsIdentityAttestationCreator aws = Mockito.mock(AwsIdentityAttestationCreator.class); |
99 | | - Mockito.when(aws.createAttestation()) |
100 | | - .thenReturn( |
101 | | - actualPresentType == AWS |
102 | | - ? new WorkloadIdentityAttestation(AWS, "aws_cred", new HashMap<>()) |
103 | | - : null); |
104 | | - GcpIdentityAttestationCreator gcp = Mockito.mock(GcpIdentityAttestationCreator.class); |
105 | | - Mockito.when(gcp.createAttestation()) |
106 | | - .thenReturn( |
107 | | - actualPresentType == GCP |
108 | | - ? new WorkloadIdentityAttestation(GCP, "gcp_cred", new HashMap<>()) |
109 | | - : null); |
110 | | - OidcIdentityAttestationCreator oidc = Mockito.mock(OidcIdentityAttestationCreator.class); |
111 | | - Mockito.when(oidc.createAttestation()) |
112 | | - .thenReturn( |
113 | | - actualPresentType == OIDC |
114 | | - ? new WorkloadIdentityAttestation(OIDC, "oidc_cred", new HashMap<>()) |
115 | | - : null); |
116 | | - AzureIdentityAttestationCreator azure = Mockito.mock(AzureIdentityAttestationCreator.class); |
117 | | - Mockito.when(azure.createAttestation()) |
118 | | - .thenReturn( |
119 | | - actualPresentType == AZURE |
120 | | - ? new WorkloadIdentityAttestation(AZURE, "azure_cred", new HashMap<>()) |
121 | | - : null); |
122 | | - return new WorkloadIdentityAttestationProvider(aws, gcp, azure, oidc); |
123 | | - } |
124 | 53 | } |
0 commit comments