-
Notifications
You must be signed in to change notification settings - Fork 790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added test case to validate both basic auth and auth2 enable api through basic auth. #13179
Open
prasa7
wants to merge
2
commits into
wso2:master
Choose a base branch
from
prasa7:master_9
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,7 +104,9 @@ public class APISecurityTestCase extends APIManagerLifecycleBaseTest { | |
private final String OauthEnabledAPIContext = "OauthEnabledAPI"; | ||
private final String apiKeySecuredAPIContext = "apiKeySecuredAPI"; | ||
private final String basicAuthSecuredAPI = "BasicAuthSecuredAPI"; | ||
private final String basicAuthAndOauth2SecuredAPI = "BasicAuthAndOauth2SecuredAPI"; | ||
private final String basicAuthSecuredAPIContext = "BasicAuthSecuredAPI"; | ||
private final String basicAuthAndOauth2SecuredAPI = "BasicAuthAndOauth2SecuredAPI"; | ||
private final String API_END_POINT_METHOD = "/customers/123"; | ||
private final String API_VERSION_1_0_0 = "1.0.0"; | ||
private final String APPLICATION_NAME = "AccessibilityOfDeprecatedOldAPIAndPublishedCopyAPITestCase"; | ||
|
@@ -119,6 +121,7 @@ public class APISecurityTestCase extends APIManagerLifecycleBaseTest { | |
private String apiId5; | ||
private String apiId6; | ||
private String apiId7; | ||
private String apiId8; | ||
private SubscriptionDTO subscriptionDTO; | ||
private final String API_RESPONSE_DATA = "<id>123</id><name>John</name></Customer>"; | ||
String users[] = {"apisecUser", "[email protected]", "[email protected]"}; | ||
|
@@ -353,6 +356,33 @@ public void initialize() | |
|
||
HttpResponse response7 = restAPIPublisher.addAPI(apiRequest7); | ||
apiId7 = response7.getData(); | ||
|
||
APIRequest apiRequest8 = new APIRequest(basicAuthAndOauth2SecuredAPI, basicAuthAndOauth2SecuredAPI, | ||
new URL(apiEndPointUrl)); | ||
apiRequest8.setVersion(API_VERSION_1_0_0); | ||
apiRequest8.setTiersCollection(APIMIntegrationConstants.API_TIER.UNLIMITED); | ||
apiRequest8.setTier(APIMIntegrationConstants.API_TIER.UNLIMITED); | ||
apiRequest8.setTags(API_TAGS); | ||
apiRequest8.setVisibility(APIDTO.VisibilityEnum.PUBLIC.getValue()); | ||
apiRequest8.setOperationsDTOS(operationsDTOS); | ||
apiRequest8.setProvider(user.getUserName()); | ||
|
||
List<String> securitySchemes8 = new ArrayList<>(); | ||
securitySchemes8.add("basic_auth"); | ||
securitySchemes8.add("oauth_basic_auth_api_key_mandatory"); | ||
securitySchemes8.add("oauth2"); | ||
apiRequest8.setSecurityScheme(securitySchemes5); | ||
apiRequest8.setDefault_version("true"); | ||
apiRequest8.setHttps_checked("https"); | ||
apiRequest8.setHttp_checked(null); | ||
HttpResponse response8 = restAPIPublisher.addAPI(apiRequest8); | ||
apiId8 = response8.getData(); | ||
createAPIRevisionAndDeployUsingRest(apiId8, restAPIPublisher); | ||
restAPIPublisher.changeAPILifeCycleStatusToPublish(apiId8, false); | ||
waitForAPIDeploymentSync(apiRequest5.getProvider(), apiRequest5.getName(), apiRequest5.getVersion(), | ||
APIMIntegrationConstants.IS_API_EXISTS); | ||
|
||
|
||
} | ||
|
||
@Test(description = "This test case tests the behaviour of internal Key token on Created API with authentication " + | ||
|
@@ -1199,6 +1229,16 @@ public void testInvocationWithApiKeysWithoutSubscription() throws Exception { | |
", but got " + invocationResponseAfterSubscriptionRemoved.getResponseCode()); | ||
} | ||
|
||
@Test(description = "Testing the invocation with Basic Auth for APIKey Only API", dependsOnMethods = { | ||
"testInvokeBasicAuthAfterCredentialsInvalid"}) | ||
public void testInvocationWithBasicAuthandOauth2ForAPIKey() throws Exception { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test method name not conveying what is tested |
||
Map<String, String> requestHeaders = new HashMap<>(); | ||
requestHeaders.put("accept", "text/xml"); | ||
requestHeaders.put("Authorization", "Basic abcce"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Header value should be set correctly |
||
HttpResponse response = HTTPSClientUtils.doGet(getAPIInvocationURLHttps(basicAuthSecuredAPIContext, | ||
API_VERSION_1_0_0) + API_END_POINT_METHOD, requestHeaders); | ||
Assert.assertEquals(response.getResponseCode(), HttpStatus.SC_OK); | ||
} | ||
@AfterClass(alwaysRun = true) | ||
public void cleanUpArtifacts() throws Exception { | ||
restAPIStore.deleteApplication(applicationId); | ||
|
@@ -1209,6 +1249,7 @@ public void cleanUpArtifacts() throws Exception { | |
restAPIPublisher.deleteAPI(apiId5); | ||
restAPIPublisher.deleteAPI(apiId6); | ||
restAPIPublisher.deleteAPI(apiId7); | ||
restAPIPublisher.deleteAPI(apiId8); | ||
removeUsers(); | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the test description