Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-alhuang committed Mar 18, 2024
1 parent 917ad39 commit 053e385
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,24 @@ public void missingOAuthParam() throws Exception {
new SFException(ErrorCode.MISSING_CONFIG, Constants.OAUTH_REFRESH_TOKEN).getMessage());
}

/** Create client with mock credential, should fail when refreshing token */
/**
* Create a client with mock credential using snowflake oauth, should fail when refreshing token
*/
@Test(expected = SecurityException.class)
public void testCreateSnowflakeOAuthClient() throws Exception {
Properties props = TestUtils.getProperties(Constants.BdecVersion.THREE, false);
props.remove(Constants.PRIVATE_KEY);
props.put(Constants.AUTHORIZATION_TYPE, Constants.OAUTH);
props.put(Constants.OAUTH_CLIENT_ID, "MOCK_CLIENT_ID");
props.put(Constants.OAUTH_CLIENT_SECRET, "MOCK_CLIENT_SECRET");
props.put(Constants.OAUTH_REFRESH_TOKEN, "MOCK_REFRESH_TOKEN");
SnowflakeStreamingIngestClient client =
SnowflakeStreamingIngestClientFactory.builder("MY_CLIENT").setProperties(props).build();
}

/**
* Create a client with mock credential using external oauth, should fail when refreshing token
*/
@Test(expected = SecurityException.class)
public void testCreateOAuthClient() throws Exception {
Properties props = TestUtils.getProperties(Constants.BdecVersion.THREE, false);
Expand All @@ -89,6 +106,7 @@ public void testCreateOAuthClient() throws Exception {
props.put(Constants.OAUTH_CLIENT_ID, "MOCK_CLIENT_ID");
props.put(Constants.OAUTH_CLIENT_SECRET, "MOCK_CLIENT_SECRET");
props.put(Constants.OAUTH_REFRESH_TOKEN, "MOCK_REFRESH_TOKEN");
props.put(Constants.OAUTH_TOKEN_ENDPOINT, "https://mockexternaloauthendpoint.test/token");
SnowflakeStreamingIngestClient client =
SnowflakeStreamingIngestClientFactory.builder("MY_CLIENT").setProperties(props).build();
}
Expand Down

0 comments on commit 053e385

Please sign in to comment.