diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java index 31adb855557..383aaa76195 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java @@ -57,9 +57,13 @@ public class IdPSuccessTest extends IdPTestBase { private static final String IDP_NAME = "Custom Auth IDP"; private static final String ENDPOINT_URI = "https://abc.com/authenticate"; private static final String UPDATED_ENDPOINT_URI = "https://xyz.com/authenticate"; + private static final String BASIC = "BASIC"; + private static final String BEARER = "BEARER"; private static final String USERNAME = "username"; private static final String PASSWORD = "password"; + private static final String ACCESS_TOKEN = "accessToken"; private static final String USERNAME_VALUE = "testUser"; + private static final String ACCESS_TOKEN_VALUE = "testBearerToken"; private static final String PASSWORD_VALUE = "testPassword"; private String idPId; private String customIdPId; @@ -81,11 +85,11 @@ public IdPSuccessTest(TestUserMode userMode) throws Exception { public void init() throws IOException { super.testInit(API_VERSION, swaggerDefinition, tenant); - userDefinedAuthenticatorPayload = createUserDefinedAuthenticatorPayload(); + userDefinedAuthenticatorPayload = createUserDefinedAuthenticatorPayloadWithBasic(ENDPOINT_URI); idpCreatePayload = readResource("add-idp-with-custom-fed-auth.json"); } - private UserDefinedAuthenticatorPayload createUserDefinedAuthenticatorPayload() { + private UserDefinedAuthenticatorPayload createUserDefinedAuthenticatorPayloadWithBasic(String endpointUri) { UserDefinedAuthenticatorPayload userDefinedAuthenticatorPayload = new UserDefinedAuthenticatorPayload(); userDefinedAuthenticatorPayload.setIsEnabled(true); @@ -93,7 +97,7 @@ private UserDefinedAuthenticatorPayload createUserDefinedAuthenticatorPayload() userDefinedAuthenticatorPayload.setDefinedBy(FederatedAuthenticatorRequest.DefinedByEnum.USER.toString()); Endpoint endpoint = new Endpoint(); - endpoint.setUri(ENDPOINT_URI); + endpoint.setUri(endpointUri); AuthenticationType authenticationType = new AuthenticationType(); authenticationType.setType(AuthenticationType.TypeEnum.BASIC); Map properties = new HashMap<>(); @@ -106,7 +110,7 @@ private UserDefinedAuthenticatorPayload createUserDefinedAuthenticatorPayload() return userDefinedAuthenticatorPayload; } - private UserDefinedAuthenticatorPayload createUserDefinedAuthenticatorPayload(String endpointUri) { + private UserDefinedAuthenticatorPayload createUserDefinedAuthenticatorPayloadWithBearer(String endpointUri) { UserDefinedAuthenticatorPayload userDefinedAuthenticatorPayload = new UserDefinedAuthenticatorPayload(); userDefinedAuthenticatorPayload.setIsEnabled(true); @@ -116,10 +120,10 @@ private UserDefinedAuthenticatorPayload createUserDefinedAuthenticatorPayload(St Endpoint endpoint = new Endpoint(); endpoint.setUri(endpointUri); AuthenticationType authenticationType = new AuthenticationType(); - authenticationType.setType(AuthenticationType.TypeEnum.BASIC); + authenticationType.setType(AuthenticationType.TypeEnum.BEARER); Map properties = new HashMap<>(); - properties.put(USERNAME, USERNAME_VALUE); - properties.put(PASSWORD, PASSWORD_VALUE); + authenticationType.setType(AuthenticationType.TypeEnum.BEARER); + properties.put(ACCESS_TOKEN, ACCESS_TOKEN_VALUE); authenticationType.setProperties(properties); endpoint.authentication(authenticationType); userDefinedAuthenticatorPayload.setEndpoint(endpoint); @@ -354,6 +358,8 @@ public void testGetUserDefinedAuthenticatorsOfIdP() { .body("defaultAuthenticatorId", equalTo(FEDERATED_AUTHENTICATOR_ID)) .body("authenticators.find { it.authenticatorId == '" + FEDERATED_AUTHENTICATOR_ID + "' }.name", equalTo(new String(Base64.getDecoder().decode(FEDERATED_AUTHENTICATOR_ID)))) + .body("authenticators.find { it.authenticatorId == '" + FEDERATED_AUTHENTICATOR_ID + "' }.isEnabled", + equalTo(true)) .body("authenticators.find { it.authenticatorId == '" + FEDERATED_AUTHENTICATOR_ID + "' }.isEnabled", equalTo(true)); } @@ -363,7 +369,8 @@ public void testUpdateUserDefinedAuthenticatorOfIdP() throws JsonProcessingExcep Response response = getResponseOfPut(IDP_API_BASE_PATH + PATH_SEPARATOR + customIdPId + PATH_SEPARATOR + IDP_FEDERATED_AUTHENTICATORS_PATH + PATH_SEPARATOR + FEDERATED_AUTHENTICATOR_ID, - createUserDefinedAuthenticatorPayload(UPDATED_ENDPOINT_URI).convertToJasonPayload()); + createUserDefinedAuthenticatorPayloadWithBearer(UPDATED_ENDPOINT_URI) + .convertToJasonPayload()); response.then() .log().ifValidationFails() @@ -371,7 +378,8 @@ public void testUpdateUserDefinedAuthenticatorOfIdP() throws JsonProcessingExcep .statusCode(HttpStatus.SC_OK) .body("authenticatorId", equalTo(FEDERATED_AUTHENTICATOR_ID)) .body("name", equalTo(new String(Base64.getDecoder().decode(FEDERATED_AUTHENTICATOR_ID)))) - .body("endpoint.uri", equalTo(UPDATED_ENDPOINT_URI)); + .body("endpoint.uri", equalTo(UPDATED_ENDPOINT_URI)) + .body("endpoint.authentication.type", equalTo(AuthenticationType.TypeEnum.BEARER.value())); } @Test(dependsOnMethods = "testUpdateUserDefinedAuthenticatorOfIdP") diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/idp/v1/empty-custom-fed-auth.json b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/idp/v1/empty-custom-fed-auth.json deleted file mode 100644 index b519af81612..00000000000 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/idp/v1/empty-custom-fed-auth.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "authenticators": [], - "defaultAuthenticatorId": "" -} \ No newline at end of file