-
Notifications
You must be signed in to change notification settings - Fork 727
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into meta-attribute-get
- Loading branch information
Showing
38 changed files
with
2,633 additions
and
37 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
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
470 changes: 470 additions & 0 deletions
470
.../src/test/java/org/wso2/identity/integration/test/oauth2/Oauth2ImpersonationTestCase.java
Large diffs are not rendered by default.
Oops, something went wrong.
335 changes: 335 additions & 0 deletions
335
...o2/identity/integration/test/rest/api/server/action/management/v1/ActionsFailureTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
469 changes: 469 additions & 0 deletions
469
...o2/identity/integration/test/rest/api/server/action/management/v1/ActionsSuccessTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
138 changes: 138 additions & 0 deletions
138
.../wso2/identity/integration/test/rest/api/server/action/management/v1/ActionsTestBase.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,138 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.wso2.identity.integration.test.rest.api.server.action.management.v1; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import io.restassured.RestAssured; | ||
import org.apache.http.HttpStatus; | ||
import org.testng.Assert; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.DataProvider; | ||
import org.wso2.carbon.automation.engine.context.TestUserMode; | ||
import org.wso2.identity.integration.test.rest.api.server.common.RESTAPIServerTestBase; | ||
|
||
import java.io.IOException; | ||
|
||
public class ActionsTestBase extends RESTAPIServerTestBase { | ||
|
||
private static final String API_DEFINITION_NAME = "Actions.yaml"; | ||
protected static final String API_VERSION = "v1"; | ||
|
||
protected static final String ACTION_MANAGEMENT_API_BASE_PATH = "/actions"; | ||
protected static final String TYPES_API_PATH = "/types"; | ||
protected static final String PRE_ISSUE_ACCESS_TOKEN_PATH = "/preIssueAccessToken"; | ||
protected static final String PRE_UPDATE_PASSWORD_PATH = "/preUpdatePassword"; | ||
protected static final String ACTION_DEACTIVATE_PATH = "/deactivate"; | ||
protected static final String ACTION_ACTIVATE_PATH = "/activate"; | ||
protected static final String ACTION_BEARER_AUTH_PATH = "/bearer"; | ||
protected static final String ACTION_BASIC_AUTH_PATH = "/basic"; | ||
|
||
protected static final String PRE_ISSUE_ACCESS_TOKEN_ACTION_TYPE = "PRE_ISSUE_ACCESS_TOKEN"; | ||
protected static final String PRE_UPDATE_PASSWORD_ACTION_TYPE = "PRE_UPDATE_PASSWORD"; | ||
|
||
protected static final String TEST_ACTION_NAME = "Access Token Pre Issue"; | ||
protected static final String TEST_ACTION_DESCRIPTION = "This is the configuration of pre-action for issuing access token."; | ||
protected static final String TEST_ACTION_ACTIVE_STATUS = "ACTIVE"; | ||
protected static final String TEST_ACTION_INACTIVE_STATUS = "INACTIVE"; | ||
protected static final String TEST_ENDPOINT_URI = "https://abc.com/token"; | ||
protected static final String TEST_USERNAME_AUTH_PROPERTY = "username"; | ||
protected static final String TEST_PASSWORD_AUTH_PROPERTY = "password"; | ||
protected static final String TEST_USERNAME_AUTH_PROPERTY_VALUE = "admin"; | ||
protected static final String TEST_PASSWORD_AUTH_PROPERTY_VALUE = "myPassword123"; | ||
protected static final String TEST_UPDATED_USERNAME_AUTH_PROPERTY_VALUE = "adminUpdated"; | ||
protected static final String TEST_UPDATED_PASSWORD_AUTH_PROPERTY_VALUE = "myPassword123Updated"; | ||
protected static final String TEST_ACTION_UPDATED_NAME = "Access Token Pre Issue Updated"; | ||
protected static final String TEST_ACTION_UPDATED_DESCRIPTION = "This is the updated configuration of pre-action for issuing access token."; | ||
protected static final String TEST_UPDATED_ENDPOINT_URI = "https://abc.com/tokenUpdated"; | ||
protected static final String TEST_PROPERTIES_AUTH_ATTRIBUTE = "properties"; | ||
protected static final String TEST_ACCESS_TOKEN_AUTH_PROPERTY = "accessToken"; | ||
protected static final String TEST_ACCESS_TOKEN_AUTH_PROPERTY_VALUE = "24f64d17-9824-4e28-8413-de45728d8e84"; | ||
protected static final String TEST_UPDATED_ACCESS_TOKEN_AUTH_PROPERTY_VALUE = "88f63a16-9824-4e28-e463-de11118d8e84"; | ||
protected static final String TEST_APIKEY_HEADER_AUTH_PROPERTY = "header"; | ||
protected static final String TEST_APIKEY_HEADER_AUTH_PROPERTY_VALUE = "key"; | ||
protected static final String TEST_APIKEY_VALUE_AUTH_PROPERTY = "value"; | ||
protected static final String TEST_APIKEY_VALUE_AUTH_PROPERTY_VALUE = "secret"; | ||
|
||
protected static String swaggerDefinition; | ||
|
||
static { | ||
String API_PACKAGE_NAME = "org.wso2.carbon.identity.api.server.action.management.v1"; | ||
try { | ||
swaggerDefinition = getAPISwaggerDefinition(API_PACKAGE_NAME, API_DEFINITION_NAME); | ||
} catch (IOException e) { | ||
Assert.fail(String.format("Unable to read the swagger definition %s from %s", API_DEFINITION_NAME, | ||
API_PACKAGE_NAME), e); | ||
} | ||
} | ||
|
||
@BeforeClass(alwaysRun = true) | ||
public void init() throws IOException { | ||
|
||
super.testInit(API_VERSION, swaggerDefinition, tenant); | ||
} | ||
|
||
@AfterClass(alwaysRun = true) | ||
public void testConclude() throws Exception { | ||
|
||
super.conclude(); | ||
} | ||
|
||
@BeforeMethod(alwaysRun = true) | ||
public void testInit() { | ||
|
||
RestAssured.basePath = basePath; | ||
} | ||
|
||
@DataProvider(name = "restAPIUserConfigProvider") | ||
public static Object[][] restAPIUserConfigProvider() { | ||
|
||
return new Object[][]{ | ||
{TestUserMode.SUPER_TENANT_ADMIN}, | ||
{TestUserMode.TENANT_ADMIN} | ||
}; | ||
} | ||
|
||
/** | ||
* Delete an Action. | ||
* | ||
* @param actionTypePath Action Type URL Path. | ||
* @param actionId ID of the Action. | ||
*/ | ||
protected void deleteAction(String actionTypePath, String actionId) { | ||
|
||
getResponseOfDelete(ACTION_MANAGEMENT_API_BASE_PATH + actionTypePath + "/" + | ||
actionId).then().assertThat().statusCode(HttpStatus.SC_NO_CONTENT); | ||
} | ||
|
||
/** | ||
* To convert object to a json string. | ||
* | ||
* @param object Respective java object. | ||
* @return Relevant json string. | ||
*/ | ||
protected String toJSONString(Object object) { | ||
|
||
Gson gson = new GsonBuilder().setPrettyPrinting().create(); | ||
return gson.toJson(object); | ||
} | ||
} | ||
|
136 changes: 136 additions & 0 deletions
136
...so2/identity/integration/test/rest/api/server/action/management/v1/model/ActionModel.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,136 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.wso2.identity.integration.test.rest.api.server.action.management.v1.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.swagger.annotations.ApiModelProperty; | ||
|
||
import java.util.Objects; | ||
|
||
import javax.validation.Valid; | ||
import javax.validation.constraints.NotNull; | ||
|
||
public class ActionModel { | ||
|
||
private String name; | ||
private String description; | ||
private Endpoint endpoint; | ||
|
||
/** | ||
**/ | ||
public ActionModel name(String name) { | ||
|
||
this.name = name; | ||
return this; | ||
} | ||
|
||
@ApiModelProperty(example = "Access Token Pre Issue", required = true, value = "") | ||
@JsonProperty("name") | ||
@Valid | ||
@NotNull(message = "Property name cannot be null.") | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
/** | ||
**/ | ||
public ActionModel description(String description) { | ||
|
||
this.description = description; | ||
return this; | ||
} | ||
|
||
@ApiModelProperty(example = "This is the configuration of pre-action for issuing access token.", value = "") | ||
@JsonProperty("description") | ||
@Valid | ||
public String getDescription() { | ||
return description; | ||
} | ||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
/** | ||
**/ | ||
public ActionModel endpoint(Endpoint endpoint) { | ||
|
||
this.endpoint = endpoint; | ||
return this; | ||
} | ||
|
||
@ApiModelProperty(required = true, value = "") | ||
@JsonProperty("endpoint") | ||
@Valid | ||
@NotNull(message = "Property endpoint cannot be null.") | ||
|
||
public Endpoint getEndpoint() { | ||
return endpoint; | ||
} | ||
public void setEndpoint(Endpoint endpoint) { | ||
this.endpoint = endpoint; | ||
} | ||
|
||
@Override | ||
public boolean equals(java.lang.Object o) { | ||
|
||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
ActionModel actionModel = (ActionModel) o; | ||
return Objects.equals(this.name, actionModel.name) && | ||
Objects.equals(this.description, actionModel.description) && | ||
Objects.equals(this.endpoint, actionModel.endpoint); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name, description, endpoint); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
sb.append("class ActionModel {\n"); | ||
sb.append(" name: ").append(toIndentedString(name)).append("\n"); | ||
sb.append(" description: ").append(toIndentedString(description)).append("\n"); | ||
sb.append(" endpoint: ").append(toIndentedString(endpoint)).append("\n"); | ||
sb.append("}"); | ||
return sb.toString(); | ||
} | ||
|
||
/** | ||
* Convert the given object to string with each line indented by 4 spaces | ||
* (except the first line). | ||
*/ | ||
private String toIndentedString(java.lang.Object o) { | ||
|
||
if (o == null) { | ||
return "null"; | ||
} | ||
return o.toString(); | ||
} | ||
} |
Oops, something went wrong.