Search in sources :

Example 26 with ApplicationDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationDTO in project product-microgateway by wso2.

the class JwtTransformerTestCase method start.

@BeforeClass
public void start() throws Exception {
    String project = "jwtTransformerProject";
    // Define application info
    Map<String, Object> claimMap = new HashMap<>();
    ApplicationDTO application = new ApplicationDTO();
    application.setName("jwtApp");
    application.setTier("Unlimited");
    application.setId((int) (Math.random() * 1000));
    JSONArray scopes = new JSONArray();
    scopes.add("admin");
    scopes.add("write");
    scopes.add("read");
    claimMap.put("scp", scopes);
    jwtTokenProdWithScopes = TokenUtil.getJwtWithCustomClaimsTransformer(application, new JSONObject(), TestConstant.KEY_TYPE_PRODUCTION, 3600, claimMap);
    // generate apis with CLI and start the micro gateway server
    super.init(project, new String[] { "jwtTransformer/jwt_transformer.yaml", "mgw-JwtValueTransformer.jar" }, null, "confs/jwt-transformer-test-config.conf");
}
Also used : ApplicationDTO(org.wso2.micro.gateway.tests.common.model.ApplicationDTO) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) JSONArray(net.minidev.json.JSONArray) JSONObject(org.json.JSONObject) BeforeClass(org.testng.annotations.BeforeClass)

Example 27 with ApplicationDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationDTO in project product-microgateway by wso2.

the class EndpointsByReferenceTestCase method start.

@BeforeClass()
public void start() throws Exception {
    String project = "EndpointReferenceProject";
    // Define application info
    ApplicationDTO application = new ApplicationDTO();
    application.setName("jwtApp");
    application.setTier("Unlimited");
    application.setId((int) (Math.random() * 1000));
    jwtTokenProd = TokenUtil.getBasicJWT(application, new JSONObject(), TestConstant.KEY_TYPE_PRODUCTION, 3600);
    String[] args = { "--myEndpoint1_prod_endpoint_0=https://localhost:2380/v1", "--myEndpoint2_prod_endpoint_0=https://localhost:2380/v2", "--myEndpoint3_prod_endpoint_0=https://localhost:2380/v1", "--myEndpoint3_prod_endpoint_1=https://localhost:2380/v2", "--myEndpoint4_prod_endpoint_1=https://localhost:2380/v2", "--myEndpoint1_prod_basic_password=admin", "--myEndpoint2_prod_basic_password=admin", "--myEndpoint3_prod_basic_password=admin", "--myEndpoint4_prod_basic_password=admin" };
    // generate apis with CLI and start the micro gateway server
    super.init(project, new String[] { "endpoints/endpoints_by_reference.yaml", "endpoints/endpoint_override.yaml", "endpoints/load_balance.yaml", "endpoints/fail_over.yaml", "endpoints/endpoint_security.yaml", "endpoints/advance_config.yaml", "endpoints/resource_endpoints_only.yaml" }, args);
}
Also used : ApplicationDTO(org.wso2.micro.gateway.tests.common.model.ApplicationDTO) JSONObject(org.json.JSONObject) BeforeClass(org.testng.annotations.BeforeClass)

Example 28 with ApplicationDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationDTO in project product-microgateway by wso2.

the class OASAPIInvokeTestCase method start.

@BeforeClass
public void start() throws Exception {
    String project = "OpenApiThrottlingProject";
    API api = new API();
    api.setName("PetStoreAPI");
    api.setContext("petstore/v1");
    api.setProdEndpoint(getMockServiceURLHttp("/echo/prod"));
    api.setVersion("1.0.0");
    api.setProvider("admin");
    // Define application info
    ApplicationDTO application = new ApplicationDTO();
    application.setName("jwtApp");
    application.setTier("Unlimited");
    application.setId((int) (Math.random() * 1000));
    jwtTokenProd = getJWT(api, application, "Unlimited", TestConstant.KEY_TYPE_PRODUCTION, 3600);
    // generate apis with CLI and start the micro gateway server
    super.init(project, new String[] { "common_api.yaml", "throttling/throttle.yaml" });
}
Also used : ApplicationDTO(org.wso2.micro.gateway.tests.common.model.ApplicationDTO) API(org.wso2.micro.gateway.tests.common.model.API) BeforeClass(org.testng.annotations.BeforeClass)

Example 29 with ApplicationDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationDTO in project product-microgateway by wso2.

the class APIKeyTestCase method start.

@BeforeClass
public void start() throws Exception {
    ApplicationDTO application = new ApplicationDTO();
    application.setName("jwtApp");
    application.setTier("Unlimited");
    application.setId((int) (Math.random() * 1000));
    jwtTokenProd = TokenUtil.getBasicJWT(application, new JSONObject(), TestConstant.KEY_TYPE_PRODUCTION, 3600);
    apiKeywithoutAllowedAPIs = "eyJhbGciOiJSUzI1NiIsICJ0eXAiOiJqd3QiLCAia2lkIjoiYmFsbGVyaW5hIn0.eyJzdWIiOiJhZG1pbiIsICJpc3M" + "iOiJodHRwczovL2xvY2FsaG9zdDo5MDk1L2FwaWtleSIsICJpYXQiOjE1ODIwMTczNTMsICJqdGkiOiI5NGFkNTk3NC1lZDI0L" + "TRjYmQtOWZlNi1iMGNmMjU5MTQ5ZDEiLCAiYXVkIjoiaHR0cDovL29yZy53c28yLmFwaW1ndC9nYXRld2F5IiwgImtleXR5cGU" + "iOiJQUk9EVUNUSU9OIiwgImFsbG93ZWRBUElzIjpbXX0.BaV6hsJUxoVEoZv2DpEg7PaE4z4q4RQ8lMLDLFDROcN5H7V4moTlk" + "Gb9tl0p3fZLPq4TGfddi53qiApQsgHG9hdd8XqrlAC47fq2ZHR-VAnWju3N-irqA6q75vfaz3g0X2A2t5e8zzcCt5YkA5ySCjI" + "FLHLR3Dxv3XBgpG7n9A8TwVywD64AZAhtnC-wgbX0uuTUSpK7BCPm-s34bChb4asrAKkDYUqzFmZTQDmL6t5lJ7QAhm3UrwuI2" + "wCAEZb6hu2YCZsrOLsX76t-2Evkx4Na-3sWIfb_2v5Arbd7PhjS6t0m5wpxCJGChDuP7dLZOXhjZGykg02uUxSt07ys1A";
    super.init("api-key-project", new String[] { "common_api.yaml" }, null, "confs/api-key.conf");
}
Also used : ApplicationDTO(org.wso2.micro.gateway.tests.common.model.ApplicationDTO) JSONObject(org.json.JSONObject) BeforeClass(org.testng.annotations.BeforeClass)

Example 30 with ApplicationDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationDTO in project product-microgateway by wso2.

the class BaseTestCase method getJWT.

protected String getJWT(API api, ApplicationDTO applicationDTO, String tier, String keyType, int validityPeriod) throws Exception {
    SubscribedApiDTO subscribedApiDTO = new SubscribedApiDTO();
    subscribedApiDTO.setContext(api.getContext() + "/" + api.getVersion());
    subscribedApiDTO.setName(api.getName());
    subscribedApiDTO.setVersion(api.getVersion());
    subscribedApiDTO.setPublisher("admin");
    subscribedApiDTO.setSubscriptionTier(tier);
    subscribedApiDTO.setSubscriberTenantDomain("carbon.super");
    JSONObject jwtTokenInfo = new JSONObject();
    jwtTokenInfo.put("subscribedAPIs", new JSONArray(Arrays.asList(subscribedApiDTO)));
    return TokenUtil.getBasicJWT(applicationDTO, jwtTokenInfo, keyType, validityPeriod);
}
Also used : SubscribedApiDTO(org.wso2.micro.gateway.tests.common.model.SubscribedApiDTO) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray)

Aggregations

BeforeClass (org.testng.annotations.BeforeClass)17 ApplicationDTO (org.wso2.micro.gateway.tests.common.model.ApplicationDTO)17 Application (org.wso2.carbon.apimgt.core.models.Application)11 ApplicationDTO (org.wso2.carbon.apimgt.rest.api.store.dto.ApplicationDTO)11 ArrayList (java.util.ArrayList)10 JSONObject (org.json.JSONObject)10 HashMap (java.util.HashMap)9 Application (org.wso2.carbon.apimgt.api.model.Application)8 API (org.wso2.micro.gateway.tests.common.model.API)8 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)7 ExportedApplication (org.wso2.carbon.apimgt.rest.api.store.v1.models.ExportedApplication)7 KeyValidationInfo (org.wso2.micro.gateway.tests.common.KeyValidationInfo)7 MockAPIPublisher (org.wso2.micro.gateway.tests.common.MockAPIPublisher)7 Test (org.junit.Test)6 APIConsumer (org.wso2.carbon.apimgt.api.APIConsumer)6 ApplicationKeysDTO (org.wso2.carbon.apimgt.rest.api.store.dto.ApplicationKeysDTO)6 ApplicationDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationDTO)6 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)5 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)5 ApplicationCreationResponse (org.wso2.carbon.apimgt.core.workflow.ApplicationCreationResponse)5