Skip to content

Commit

Permalink
Address comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Dec 18, 2024
1 parent dab35c5 commit d21f0eb
Showing 1 changed file with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
import java.io.IOException;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.IsNull.notNullValue;

/**
Expand All @@ -58,6 +59,8 @@ public class AuthenticatorSuccessTest extends AuthenticatorTestBase {
private UserDefinedLocalAuthenticatorUpdate updatePayload;

private final String CUSTOM_TAG = "Custom";
private final String[] CURRENT_TAGS_LIST = new String[]{"APIAuth","MFA","Passwordless","Passkey",
"Username-Password", "Request-Path","Social-Login","OIDC","SAML","Enterprise"};

@Factory(dataProvider = "restAPIUserConfigProvider")
public AuthenticatorSuccessTest(TestUserMode userMode) throws Exception {
Expand Down Expand Up @@ -129,27 +132,18 @@ public void getAuthenticators() throws JSONException {
}

@Test(dependsOnMethods = {"getAuthenticators"})
public void testGetMetaTags() throws JsonProcessingException {
public void testGetMetaTags() {

Response responseBefore = getResponseOfGet(AUTHENTICATOR_META_TAGS_PATH);
responseBefore.then()
Response response = getResponseOfGet(AUTHENTICATOR_META_TAGS_PATH);
response.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK)
.body("$", not(hasItem(CUSTOM_TAG)));

getResponseOfPost(AUTHENTICATOR_CUSTOM_API_BASE_PATH,
UserDefinedLocalAuthenticatorPayload.convertToJasonPayload(creationPayload));

Response responseAfter = getResponseOfGet(AUTHENTICATOR_META_TAGS_PATH);
responseAfter.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK)
.body("$", hasItem(CUSTOM_TAG));

getResponseOfDelete(AUTHENTICATOR_CUSTOM_API_BASE_PATH + PATH_SEPARATOR
+ customIdPId);
for (String tag : CURRENT_TAGS_LIST) {
response.then()
.body("$", hasItem(tag));
}
}

@Test(dependsOnMethods = {"testGetMetaTags"})
Expand All @@ -168,7 +162,7 @@ public void testCreateUserDefinedLocalAuthenticator() throws JsonProcessingExcep
.body("type", equalTo("LOCAL"))
.body("definedBy", equalTo("USER"))
.body("isEnabled", equalTo(true))
.body("tags", hasItems(CUSTOM_TAG))
.body("tags", hasItem(CUSTOM_TAG))
.body("self", equalTo(getTenantedRelativePath(
AUTHENTICATOR_CONFIG_API_BASE_PATH + customIdPId, tenant)));
}
Expand Down Expand Up @@ -201,6 +195,21 @@ public void getUserDefinedLocalAuthenticators() throws JSONException {
Assert.assertTrue(isUserDefinedAuthenticatorFound);
}

@Test(dependsOnMethods = {"testCreateUserDefinedLocalAuthenticator"})
public void testValidateCustomTagInGetMetaTags() {

Response response = getResponseOfGet(AUTHENTICATOR_META_TAGS_PATH);
response.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK)
.body("$", hasItem(CUSTOM_TAG));
for (String tag : CURRENT_TAGS_LIST) {
response.then()
.body("$", hasItem(tag));
}
}

@Test(dependsOnMethods = {"testCreateUserDefinedLocalAuthenticator"})
public void testUpdateUserDefinedLocalAuthenticator() throws JsonProcessingException {

Expand All @@ -220,7 +229,7 @@ public void testUpdateUserDefinedLocalAuthenticator() throws JsonProcessingExcep
.body("type", equalTo("LOCAL"))
.body("definedBy", equalTo("USER"))
.body("isEnabled", equalTo(false))
.body("tags", hasItems(CUSTOM_TAG))
.body("tags", hasItem(CUSTOM_TAG))
.body("self", equalTo(getTenantedRelativePath(
AUTHENTICATOR_CONFIG_API_BASE_PATH + customIdPId, tenant)));
}
Expand Down

0 comments on commit d21f0eb

Please sign in to comment.