Skip to content

Commit

Permalink
Merge pull request #22327 from Thisara-Welmilla/fix-integration-test-…
Browse files Browse the repository at this point in the history
…idp-test

Fix integration tests.
  • Loading branch information
Thisara-Welmilla authored Jan 21, 2025
2 parents 1699972 + 0ecae81 commit 182a452
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ public void createUserDefinedLocalAuthenticatorMissingEndpointProperty() throws
}

@Test(priority = 3)
public void createUserDefinedLocalAuthenticatorEmptyDisplayName() throws JsonProcessingException {
public void createUserDefinedLocalAuthenticatorTwoCharacterDisplayName() throws JsonProcessingException {

creationPayload.setDisplayName("");
String displayName = "te";
creationPayload.setDisplayName(displayName);
String body = UserDefinedLocalAuthenticatorPayload.convertToJasonPayload(creationPayload);
Response response = getResponseOfPost(AUTHENTICATOR_CUSTOM_API_BASE_PATH, body);
response.then()
Expand All @@ -148,8 +149,8 @@ public void createUserDefinedLocalAuthenticatorEmptyDisplayName() throws JsonPro
.statusCode(HttpStatus.SC_BAD_REQUEST)
.body("code", equalTo("AUT-60015"))
.body("message", equalTo("Authenticator display name is invalid."))
.body("description", equalTo(
"The provided authenticator name is not in the expected format ^.{3,}$."));
.body("description", equalTo(String.format(
"The provided authenticator name %s is not in the expected format ^.{3,}$.", displayName)));
}

@Test(priority = 4)
Expand Down Expand Up @@ -267,7 +268,8 @@ public void updateUserDefinedLocalAuthenticatorMissingEndpointProperty() throws
@Test(priority = 11)
public void updateUserDefinedLocalAuthenticatorEmptyDisplayName() throws JsonProcessingException {

updatePayload.setDisplayName("");
String displayName = "";
updatePayload.setDisplayName(displayName);
String body = UserDefinedLocalAuthenticatorPayload.convertToJasonPayload(updatePayload);
Response response = getResponseOfPutWithNoFilter(AUTHENTICATOR_CUSTOM_API_BASE_PATH + PATH_SEPARATOR +
customIdPId, body);
Expand All @@ -277,8 +279,8 @@ public void updateUserDefinedLocalAuthenticatorEmptyDisplayName() throws JsonPro
.statusCode(HttpStatus.SC_BAD_REQUEST)
.body("code", equalTo("AUT-60015"))
.body("message", equalTo("Authenticator display name is invalid."))
.body("description", equalTo(
"The provided authenticator name is not in the expected format ^.{3,}$."));
.body("description", equalTo(String.format(
"The provided authenticator name %s is not in the expected format ^.{3,}$.", displayName)));
}

@Test(priority = 12)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class IdPFailureTest extends IdPTestBase {
private String idPId;
private String idpCreatePayload;
private static final String OIDC_IDP_ID = "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I";
private static final String CONFLICTING_AUTH_NAME = "Y3VzdG9tX2NvbmZsaWN0QXV0aE5hbWU=";
private static final String CONFLICTING_AUTH_NAME = "Y3VzdG9tLWNvbmZsaWN0QXV0aE5hbWU=";

@Factory(dataProvider = "restAPIUserConfigProvider")
public IdPFailureTest(TestUserMode userMode) throws Exception {
Expand All @@ -86,7 +86,6 @@ public void init() throws IOException {

super.testInit(API_VERSION, swaggerDefinition, tenant);
idpCreatePayload = readResource("add-idp-with-custom-fed-auth.json");
createUserDefinedLocalAuthenticator();
}

@AfterClass(alwaysRun = true)
Expand Down Expand Up @@ -247,6 +246,7 @@ public void testAddIdPWithUserDefinedAuthenticatorWhenEndpointUriIsEmpty() throw
@Test
public void testAddIdPWithUserDefinedAuthenticatorWithExistingAuthName() throws IOException {

createUserDefinedLocalAuthenticator();
UserDefinedAuthenticatorPayload userDefAuthPayload = createUserDefinedAuthenticatorPayload(
CONFLICTING_AUTH_NAME,
"https://abc.com/authenticate",
Expand All @@ -257,8 +257,10 @@ public void testAddIdPWithUserDefinedAuthenticatorWithExistingAuthName() throws
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_BAD_REQUEST)
.body("message", equalTo("Invalid Request"))
.body("description", equalTo("must match \"^https?://.+\""));
.body("message", equalTo(
"Federated authenticator name custom-conflictAuthName is already taken."))
.body("description", equalTo(
"Federated authenticator name custom-conflictAuthName is already taken."));
}

@Test
Expand Down Expand Up @@ -742,15 +744,18 @@ private String convertDuplicatedPropertiesToJson(Map<String, String> properties,
private void createUserDefinedLocalAuthenticator() throws JsonProcessingException {

String body = "{\n" +
" \"name\": \"custom_conflictAuthName\",\n" +
" \"name\": \"custom-conflictAuthName\",\n" +
" \"displayName\": \"Custom auth\",\n" +
" \"isEnabled\": true,\n" +
" \"description\": \"The user defined custom local authenticator.\",\n" +
" \"authenticationType\": \"IDENTIFICATION\",\n" +
" \"endpoint\": {\n" +
" \"uri\": \"https://abc.com/token\",\n" +
" \"authentication\": {\n" +
" \"type\": \"NONE\",\n" +
"\n" +
" \"type\": \"BASIC\",\n" +
" \"properties\": {\n" +
" \"username\": \"auth_username\",\n" +
" \"password\": \"auth_password\"\n" +
" }\n" +
" }\n" +
" }\n" +
"}";
Expand Down

0 comments on commit 182a452

Please sign in to comment.