Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,24 @@ private static AbstractAuthenticationDetailsProvider getAuthenticationDetails(
* Returns authentication details using the following API key-based
* methods:
* <ol>
* <li>Simple authentication: if any of the credentials, including tenant ID
* , user ID, fingerprint, private key, or passphrase, are provided in
* the given {@code parameters}</li>
* <li>Simple authentication: if all required credentials (tenant ID,
* user ID, fingerprint, and private key are provided in the given
* {@code parameters}</li>
* <li>Config File (API key) authentication: otherwise</li>
* </ol>
* @return API key-based authentication details
*/
private static AuthenticationDetailsProvider
apiKeyBasedAuthentication(ParameterSet parameters) {
if (parameters.contains(TENANT_ID)
|| parameters.contains(USER_ID)
|| parameters.contains(FINGERPRINT)
|| parameters.contains(PRIVATE_KEY)
|| parameters.contains(PASS_PHRASE)
|| parameters.contains(REGION)) {
boolean hasAllRequiredKeys =
parameters.contains(TENANT_ID)
&& parameters.contains(USER_ID)
&& parameters.contains(FINGERPRINT)
&& parameters.contains(PRIVATE_KEY);

if(hasAllRequiredKeys)
return simpleAuthentication(parameters);
}

return configFileAuthentication(parameters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ public void testConfigFile() {
.build());
}

/**
* Verifies partial API_KEY credentials fallback to config file.
*/
@Test
public void testApiKeyPartialCredentials() {
verifyAuthenticationDetails(
buildParameterSet(AuthenticationMethod.API_KEY)
.add("Test OCI_USER", AuthenticationDetailsFactory.USER_ID, "dummy-user-id")
.build());
}

/**
* Verifies {@link AuthenticationMethod#CLOUD_SHELL}
*/
Expand Down