Skip to content

Commit

Permalink
Merge branch 'master' into meta-attribute-get
Browse files Browse the repository at this point in the history
  • Loading branch information
HasiniSama authored Jul 24, 2024
2 parents 17ac75f + b869b87 commit 2d9b535
Show file tree
Hide file tree
Showing 38 changed files with 2,633 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Building the distribution from source
- `mvn clean install` (To build the binary and source distributions with the tests)
- `mvn clean install -Dmaven.test.skip=true` (To build the binary and source distribution, without running any of
the unit/integration tests)
5. You can find the binary distribution in product-is/modules/distribution/target directory.
5. You can find the binary distribution in `product-is/modules/distribution/target` directory.


Installation and Running
Expand Down
8 changes: 8 additions & 0 deletions modules/api-resources/api-resources-full/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -488,5 +488,13 @@
<groupId>org.wso2.carbon.identity.server.api</groupId>
<artifactId>org.wso2.carbon.identity.api.server.organization.selfservice.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.server.api</groupId>
<artifactId>org.wso2.carbon.identity.api.server.action.management.v1</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.server.api</groupId>
<artifactId>org.wso2.carbon.identity.api.server.action.management.common</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<import resource="classpath:META-INF/cxf/org-role-mgt-server-v1-cxf.xml"/>
<import resource="classpath:META-INF/cxf/user-organization-v1-cxf.xml"/>
<import resource="classpath:META-INF/cxf/api-resource-server-v1-cxf.xml"/>
<import resource="classpath:META-INF/cxf/action-server-v1-cxf.xml"/>

<context:property-placeholder/>
<context:annotation-config/>
Expand Down Expand Up @@ -143,6 +144,7 @@
<bean class="org.wso2.carbon.identity.api.server.api.resource.v1.ScopesApi"/>
<bean class="org.wso2.carbon.identity.api.server.organization.selfservice.v1.SelfServiceApi"/>
<bean class="org.wso2.carbon.identity.api.server.api.resource.v1.MetaApi"/>
<bean class="org.wso2.carbon.identity.api.server.action.management.v1.ActionsApi"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider">
Expand Down
10 changes: 10 additions & 0 deletions modules/api-resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,16 @@
<artifactId>org.wso2.carbon.identity.api.server.api.resource.common</artifactId>
<version>${identity.server.api.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.server.api</groupId>
<artifactId>org.wso2.carbon.identity.api.server.action.management.v1</artifactId>
<version>${identity.server.api.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.server.api</groupId>
<artifactId>org.wso2.carbon.identity.api.server.action.management.common</artifactId>
<version>${identity.server.api.version}</version>
</dependency>

<!-- Legacy API dependencies -->
<dependency>
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

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);
}
}

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();
}
}
Loading

0 comments on commit 2d9b535

Please sign in to comment.