Skip to content

Commit 4b4df3a

Browse files
SNOW-3677756: Add e2e test for GetWebIdentityToken opt-in WIF path (#2677)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent a1f4bca commit 4b4df3a

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

ci/wif/aws-lambda/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ run_aws_function() {
2424
local aws_version
2525
aws_version=$(aws --version 2>&1 | head -n1)
2626

27-
local payload_json="{\"queryStringParameters\":{\"SNOWFLAKE_TEST_WIF_HOST\":\"${SNOWFLAKE_TEST_WIF_HOST_AWS}\",\"SNOWFLAKE_TEST_WIF_ACCOUNT\":\"${SNOWFLAKE_TEST_WIF_ACCOUNT}\",\"SNOWFLAKE_TEST_WIF_PROVIDER\":\"AWS\",\"BRANCH\":\"${BRANCH}\"}}"
27+
local payload_json="{\"queryStringParameters\":{\"SNOWFLAKE_TEST_WIF_HOST\":\"${SNOWFLAKE_TEST_WIF_HOST_AWS}\",\"SNOWFLAKE_TEST_WIF_ACCOUNT\":\"${SNOWFLAKE_TEST_WIF_ACCOUNT}\",\"SNOWFLAKE_TEST_WIF_PROVIDER\":\"AWS\",\"BRANCH\":\"${BRANCH}\",\"SNOWFLAKE_TEST_WIF_OUTBOUND_TOKEN_IMPERSONATION_PATH\":\"${SNOWFLAKE_TEST_WIF_OUTBOUND_TOKEN_IMPERSONATION_PATH:-}\",\"SNOWFLAKE_TEST_WIF_OUTBOUND_TOKEN_USER\":\"${SNOWFLAKE_TEST_WIF_OUTBOUND_TOKEN_USER:-}\"}}"
2828
local function_name="drivers-wif-automated-tests"
2929

3030
local cli_response_file="/tmp/aws_cli_response_$$.json"

ci/wif/shared/com/snowflake/wif/common/WifTestHelper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ public static int executeMavenBuild(String repoFolderPath, String tempDirectory,
144144
pb.environment().put("SNOWFLAKE_TEST_WIF_AWS_EXTERNAL_ID", externalId);
145145
}
146146

147+
String outboundTokenImpersonationPath = queryParams.get("SNOWFLAKE_TEST_WIF_OUTBOUND_TOKEN_IMPERSONATION_PATH");
148+
if (outboundTokenImpersonationPath != null) {
149+
pb.environment().put("SNOWFLAKE_TEST_WIF_OUTBOUND_TOKEN_IMPERSONATION_PATH", outboundTokenImpersonationPath);
150+
}
151+
String outboundTokenUser = queryParams.get("SNOWFLAKE_TEST_WIF_OUTBOUND_TOKEN_USER");
152+
if (outboundTokenUser != null) {
153+
pb.environment().put("SNOWFLAKE_TEST_WIF_OUTBOUND_TOKEN_USER", outboundTokenUser);
154+
}
155+
147156
process = pb.start();
148157

149158
final InputStream processInputStream = process.getInputStream();

src/test/java/net/snowflake/client/wif/WIFLatestIT.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public class WIFLatestIT {
4545
System.getenv("SNOWFLAKE_TEST_WIF_IMPERSONATION_ROLE_ARN_WITH_EXTERNAL_ID");
4646
private static final String IMPERSONATION_USER_WITH_EXTERNAL_ID =
4747
System.getenv("SNOWFLAKE_TEST_WIF_IMPERSONATION_USER_WITH_EXTERNAL_ID");
48+
private static final String OUTBOUND_TOKEN_IMPERSONATION_PATH =
49+
"arn:aws:iam::376129840140:role/drivers-wif-automated-tests-with-issuer";
50+
private static final String OUTBOUND_TOKEN_USER = "TEST_WIF_E2E_AWS_WITH_ISSUER";
4851

4952
@Test
5053
void shouldAuthenticateUsingWIFWithDefinedProvider() {
@@ -145,6 +148,18 @@ private void connectAndExecuteSimpleQuery(Properties props, String expectedUser)
145148
}
146149
}
147150

151+
@Test
152+
@EnabledIf("isProviderAWS")
153+
void shouldAuthenticateUsingWIFWithGetWebIdentityToken() {
154+
Properties properties = new Properties();
155+
properties.put("account", ACCOUNT);
156+
properties.put("authenticator", "WORKLOAD_IDENTITY");
157+
properties.put("workloadIdentityProvider", "AWS");
158+
properties.put("workloadIdentityAwsUseOutboundToken", "true");
159+
properties.put("workloadIdentityImpersonationPath", OUTBOUND_TOKEN_IMPERSONATION_PATH);
160+
connectAndExecuteSimpleQuery(properties, OUTBOUND_TOKEN_USER);
161+
}
162+
148163
@Test
149164
@EnabledIf("isProviderAWS")
150165
@EnabledIfEnvironmentVariable(

0 commit comments

Comments
 (0)