-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cucumber test for visibility feature
- Loading branch information
Showing
6 changed files
with
122 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
test/cucumber-tests/src/test/java/org/wso2/apk/integration/api/BackOfficeSteps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.wso2.apk.integration.api; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import io.cucumber.java.en.When; | ||
|
||
import org.apache.http.HttpResponse; | ||
import org.wso2.apk.integration.utils.Constants; | ||
import org.wso2.apk.integration.utils.Utils; | ||
import org.wso2.apk.integration.utils.clients.SimpleHTTPClient; | ||
|
||
public class BackOfficeSteps { | ||
|
||
private final SharedContext sharedContext; | ||
|
||
public BackOfficeSteps(SharedContext sharedContext) { | ||
|
||
this.sharedContext = sharedContext; | ||
} | ||
|
||
@When("I make the GET APIs call to the backoffice") | ||
public void make_a_deployment_request() throws Exception { | ||
Map<String, String> headers = new HashMap<>(); | ||
headers.put(Constants.REQUEST_HEADERS.AUTHORIZATION, "Bearer " + sharedContext.getAccessToken()); | ||
headers.put(Constants.REQUEST_HEADERS.HOST, Constants.DEFAULT_API_HOST); | ||
|
||
HttpResponse response = sharedContext.getHttpClient().doGet(Utils.getBackOfficeAPIURL(), | ||
headers); | ||
|
||
sharedContext.setResponse(response); | ||
sharedContext.setResponseBody(SimpleHTTPClient.responseEntityBodyToString(sharedContext.getResponse())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/cucumber-tests/src/test/resources/tests/api/Visibility.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Feature: API Visibility and Access Control | ||
Scenario: View APIs with a groups claim and API view scope in the access token | ||
Given The system is ready | ||
And I have a valid subscription with groups | ||
| group1 | | ||
When I make the GET APIs call to the backoffice | ||
Then the response status code should be 200 | ||
And the response body should contain "\"count\":1" | ||
|
||
Scenario: View APIs without a groups claim in the access token | ||
Given The system is ready | ||
And I have a valid subscription with scopes | ||
| apk:api_view | | ||
When I make the GET APIs call to the backoffice | ||
Then the response status code should be 200 | ||
And the response body should contain "\"count\":0" |