Skip to content

Commit

Permalink
Merge pull request #13303 from GihanAyesh/revocationmain
Browse files Browse the repository at this point in the history
shared application api key revocation test case
  • Loading branch information
GihanAyesh authored Dec 13, 2023
2 parents 5c00b84 + e2030b4 commit 9be9202
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.wso2.am.integration.clients.store.api.ApiException;
import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationDTO;
import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationInfoDTO;
import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationKeyGenerateRequestDTO;
import org.wso2.am.integration.clients.store.api.v1.dto.APIKeyDTO;
import org.wso2.am.integration.test.impl.RestAPIStoreImpl;
import org.wso2.am.integration.test.utils.UserManagementUtils;
import org.wso2.am.integration.test.utils.base.APIMIntegrationBaseTest;
Expand Down Expand Up @@ -79,8 +81,8 @@ public static Object[][] userModeDataProvider() {
public void setEnvironment() throws Exception {

super.init(userMode);
createUsersAndApplications();
groups.add(ORGANIZATION);
createUsersAndApplications();
}

@Test(groups = "wso2.am", description = "Remove user one's application and check if user two's application also " +
Expand Down Expand Up @@ -125,6 +127,23 @@ public void testEditApplicationByUserInApplicationGroup() throws ApiException {
Assert.assertEquals(serviceResponse.getResponseCode(), HttpStatus.SC_FORBIDDEN);
}

@Test(groups = "wso2.am", description = "Generate API key from user 1 and make sure that user 2 can revoke the key")
public void testAPIKeyRevocationBySharedUser()
throws ApiException {

//Check for application availability
List<ApplicationInfoDTO> user1AllAppsList = restAPIStoreClientUser1.getAllApps().getList();
ApplicationDTO applicationDTO = restAPIStoreClientUser1.getApplicationById(userOneSharedApplicationId);
Assert.assertNotNull(applicationDTO);
Assert.assertEquals(applicationDTO.getName(), SHARED_APPLICATION_NAME);

//Generate api key by user 1
APIKeyDTO key = restAPIStoreClientUser1.generateAPIKeys(userOneSharedApplicationId,
ApplicationKeyGenerateRequestDTO.KeyTypeEnum.PRODUCTION.toString(), -1, null, null);
//Revoke api key by user 2
restAPIStoreClientUser2.revokeAPIKey(userOneSharedApplicationId, key.getApikey());
}

@AfterClass(alwaysRun = true)
public void destroy() throws Exception {
restAPIStoreClientUser2.removeApplicationById(userTwoApplicationId);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@
<carbon.apimgt.ui.version>9.0.476</carbon.apimgt.ui.version>

<!-- APIM Component Version -->
<carbon.apimgt.version>9.28.190</carbon.apimgt.version>
<carbon.apimgt.version>9.28.195</carbon.apimgt.version>

<carbon.apimgt.imp.pkg.version>[9.0.0, 10.0.0)</carbon.apimgt.imp.pkg.version>

Expand Down

0 comments on commit 9be9202

Please sign in to comment.