From 6593531a615bd4f8159a9e6a68ab011e510794ad Mon Sep 17 00:00:00 2001 From: Davids-98 Date: Tue, 4 Apr 2023 11:47:42 +0530 Subject: [PATCH 1/3] integration test for issue #2033 --- ...OAuth2ServiceClientCredentialTestCase.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java index c746736deb..a3cca94290 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java @@ -133,7 +133,10 @@ public void testGetTokenUsingClientCredentialsGrant() throws Exception { ClientID clientID = new ClientID(consumerKey); Secret clientSecret = new Secret(consumerSecret); ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret); - Scope scope = new Scope(OAUTH2_SCOPE_OPENID, "xyz"); + + //Add email, profile scopes to the request. + Scope scope = new Scope(OAuth2Constant.OAUTH2_SCOPE_OPENID, OAuth2Constant.OAUTH2_SCOPE_EMAIL, + OAuth2Constant.OAUTH2_SCOPE_PROFILE, "xyz"); URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, clientCredentialsGrant, scope); @@ -154,9 +157,17 @@ public void testGetTokenUsingClientCredentialsGrant() throws Exception { Assert.assertTrue(scopesInResponse.contains("xyz"), "Requested scope is missing in the token response"); // This ensures that openid scopes are not issued for client credential grant type. - Assert.assertFalse(accessTokenResponse instanceof OIDCTokenResponse, "Client credential grant type cannot " + - "get a OIDC Token Response."); - Assert.assertFalse(scopesInResponse.contains(OAUTH2_SCOPE_OPENID), "Client credentials cannot get openid scope."); + Assert.assertFalse(accessTokenResponse instanceof OIDCTokenResponse, + "Client credential grant type cannot " + + "get a OIDC Token Response."); + Assert.assertFalse(scopesInResponse.contains(OAUTH2_SCOPE_OPENID), + "Client credentials cannot get openid scope."); + + Assert.assertFalse(scopesInResponse.contains(OAuth2Constant.OAUTH2_SCOPE_EMAIL), + "Client credentials cannot get " + + "email scope."); + Assert.assertFalse(scopesInResponse.contains(OAuth2Constant.OAUTH2_SCOPE_PROFILE), + "Client credentials cannot get " + "profile scope."); } @Test(groups = "wso2.is", description = "Validate access token", From e0c74619ca41340fe9eb7ce8bbdb235746595696 Mon Sep 17 00:00:00 2001 From: Davids-98 Date: Tue, 4 Apr 2023 11:54:44 +0530 Subject: [PATCH 2/3] integration test for issue #2033 --- .../oauth2/OAuth2ServiceClientCredentialTestCase.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java index a3cca94290..4bac6a83d1 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java @@ -158,16 +158,14 @@ public void testGetTokenUsingClientCredentialsGrant() throws Exception { // This ensures that openid scopes are not issued for client credential grant type. Assert.assertFalse(accessTokenResponse instanceof OIDCTokenResponse, - "Client credential grant type cannot " + - "get a OIDC Token Response."); + "Client credential grant type cannot get a OIDC Token Response."); Assert.assertFalse(scopesInResponse.contains(OAUTH2_SCOPE_OPENID), "Client credentials cannot get openid scope."); Assert.assertFalse(scopesInResponse.contains(OAuth2Constant.OAUTH2_SCOPE_EMAIL), - "Client credentials cannot get " + - "email scope."); + "Client credentials cannot get email scope."); Assert.assertFalse(scopesInResponse.contains(OAuth2Constant.OAUTH2_SCOPE_PROFILE), - "Client credentials cannot get " + "profile scope."); + "Client credentials cannot get profile scope."); } @Test(groups = "wso2.is", description = "Validate access token", From 70618ad88d023b26f3316c7e63a8dfe89860e659 Mon Sep 17 00:00:00 2001 From: Farasath Ahamed Date: Fri, 30 Jun 2023 17:05:24 +0530 Subject: [PATCH 3/3] Update modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java --- .../test/oauth2/OAuth2ServiceClientCredentialTestCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java index 4bac6a83d1..5b810f82a4 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java @@ -134,7 +134,7 @@ public void testGetTokenUsingClientCredentialsGrant() throws Exception { Secret clientSecret = new Secret(consumerSecret); ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret); - //Add email, profile scopes to the request. + // Add email, profile scopes to the request. Scope scope = new Scope(OAuth2Constant.OAUTH2_SCOPE_OPENID, OAuth2Constant.OAUTH2_SCOPE_EMAIL, OAuth2Constant.OAUTH2_SCOPE_PROFILE, "xyz");