Java Code Examples for org.wso2.carbon.apimgt.api.model.API#setContextTemplate()

The following examples show how to use org.wso2.carbon.apimgt.api.model.API#setContextTemplate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: APIMgtDAOTest.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Test
public void testLifeCycleEvents() throws Exception {
    APIIdentifier apiId = new APIIdentifier("hiranya", "WSO2Earth", "1.0.0");
    API api = new API(apiId);
    api.setContext("/wso2earth");
    api.setContextTemplate("/wso2earth/{version}");

    apiMgtDAO.addAPI(api, -1234);

    List<LifeCycleEvent> events = apiMgtDAO.getLifeCycleEvents(apiId);
    assertEquals(1, events.size());
    LifeCycleEvent event = events.get(0);
    assertEquals(apiId, event.getApi());
    assertNull(event.getOldStatus());
    assertEquals(APIConstants.CREATED, event.getNewStatus());
    assertEquals("hiranya", event.getUserId());

    apiMgtDAO.recordAPILifeCycleEvent(apiId, APIStatus.CREATED, APIStatus.PUBLISHED, "admin", -1234);
    apiMgtDAO.recordAPILifeCycleEvent(apiId, APIStatus.PUBLISHED, APIStatus.DEPRECATED, "admin", -1234);
    events = apiMgtDAO.getLifeCycleEvents(apiId);
    assertEquals(3, events.size());
}
 
Example 2
Source File: TransportConfigContextTest.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Test
public void testTransportConfigContext() throws Exception {

    API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
    api.setStatus(APIConstants.CREATED);
    api.setContextTemplate("/");
    api.setTransports(Constants.TRANSPORT_HTTP);
    ConfigContext configcontext = new APIConfigContext(api);
    TransportConfigContext transportConfigContext = new TransportConfigContext(configcontext, api);
    transportConfigContext.validate();
    Assert.assertTrue(Constants.TRANSPORT_HTTP.equalsIgnoreCase
            (transportConfigContext.getContext().get("transport").toString()));
    api.setTransports(Constants.TRANSPORT_HTTP + "," + Constants.TRANSPORT_HTTPS);
    configcontext = new APIConfigContext(api);
    transportConfigContext = new TransportConfigContext(configcontext, api);
    Assert.assertTrue(StringUtils.EMPTY.equalsIgnoreCase
            (transportConfigContext.getContext().get("transport").toString()));
}
 
Example 3
Source File: APIMgtDAOTest.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Test
 public void testAddAndConvertNullThrottlingTiers() throws APIManagementException {

     //Adding an API with a null THROTTLING_TIER should automatically convert it to Unlimited
     APIIdentifier apiIdentifier = new APIIdentifier("testAddAndGetApi", "testAddAndGetApi", "1.0.0");
     API api = new API(apiIdentifier);
     api.setContext("/testAddAndGetApi");
     api.setContextTemplate("/testAddAndGetApi/{version}");
     Set<URITemplate> uriTemplates = new HashSet<URITemplate>();
     uriTemplates.add(getUriTemplate("/abc", "GET", "Any", "read", null));
     api.setUriTemplates(uriTemplates);
     api.setScopes(getScopes());
     api.setStatus(APIConstants.PUBLISHED);
     api.setAsDefaultVersion(true);
     int apiId = apiMgtDAO.addAPI(api, -1234);
     apiMgtDAO.addURITemplates(apiId, api, -1234);
     HashMap<String, String> result1 = apiMgtDAO.getURITemplatesPerAPIAsString(apiIdentifier);
     Assert.assertTrue(result1.containsKey("/abc::GET::Any::Unlimited::abcd defgh fff"));

     //Change the inserted throttling tier back to Null and test the convertNullThrottlingTier method
     updateThrottlingTierToNull();
     apiMgtDAO.convertNullThrottlingTiers();
     HashMap<String, String> result2 = apiMgtDAO.getURITemplatesPerAPIAsString(apiIdentifier);
     Assert.assertTrue(result2.containsKey("/abc::GET::Any::Unlimited::abcd defgh fff"));
}
 
Example 4
Source File: EnvironmentConfigContextTest.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Test
public void testEnvironmentConfigContext() throws Exception {

    API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
    api.setStatus(APIConstants.CREATED);
    api.setContextTemplate("/");
    String url = "http://maps.googleapis.com/maps/api/geocode/json?address=Colombo";
    String endpointConfig = "{\"production_endpoints\":{\"url\":\"" + url + "\", \"config\":null}," +
            "\"sandbox_endpoint\":{\"url\":\"" + url + "\",\"config\":null},\"endpoint_type\":\"http\"}";
    api.setEndpointConfig(endpointConfig);
    api.setUrl(url);
    api.setSandboxUrl(url);
    ConfigContext configcontext = new APIConfigContext(api);
    Environment environment = new Environment();
    environment.setType("production");
    EnvironmentConfigContext environmentConfigContext = new EnvironmentConfigContext(configcontext, environment);
    Assert.assertNotNull(environmentConfigContext.getContext().get("environment"));
    Assert.assertNotNull(environmentConfigContext.getContext().get("environmentType"));
}
 
Example 5
Source File: EndpointBckConfigContextTest.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Test
public void testEndpointBckConfigContext() throws Exception {
    API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
    api.setStatus(APIConstants.CREATED);
    api.setContextTemplate("/");
    String url = "http://maps.googleapis.com/maps/api/geocode/json?address=Colombo";
    api.setUrl(url);
    api.setSandboxUrl(url);
    ConfigContext configcontext = new APIConfigContext(api);
    EndpointBckConfigContext endpointBckConfigContext = new EndpointBckConfigContext(configcontext, api);
    Assert.assertTrue(api.getEndpointConfig().contains(url));
    //setting an empty string as the endpoint config and checking the value which is returned
    api.setEndpointConfig("");
    String endpoint_config = "{\"production_endpoints\":{\"url\":\"" + api.getUrl() + "\", \"config\":null}," +
            "\"sandbox_endpoint\":{\"url\":\"" + api.getSandboxUrl() + "\"," +
            "\"config\":null},\"endpoint_type\":\"http\"}";
    EndpointBckConfigContext secondEndpointBckConfigContext = new EndpointBckConfigContext(configcontext, api);
    Assert.assertTrue(api.getEndpointConfig().contains(endpoint_config));
    //setting null as the endpoint config and checking the value which is returned
    api.setEndpointConfig(null);
    EndpointBckConfigContext thirdEndpointBckConfigContext = new EndpointBckConfigContext(configcontext, api);
    Assert.assertTrue(api.getEndpointConfig().contains(endpoint_config));
}
 
Example 6
Source File: TemplateUtilContextTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void testTemplateUtilContext() throws Exception {
    API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
    api.setStatus(APIConstants.CREATED);
    api.setContextTemplate("/");
    ConfigContext configcontext = new APIConfigContext(api);
    TemplateUtilContext templateUtilContext = new TemplateUtilContext(configcontext);
    String xmlSampleText = "<data>TemplateUtilContextTest Class</data>";
    String xmlEscapedText = "&lt;data&gt;TemplateUtilContextTest Class&lt;/data&gt;";
    String result = templateUtilContext.escapeXml(xmlSampleText);
    Assert.assertTrue("Failed to escape XML tags in the provided string : " + xmlSampleText,
            xmlEscapedText.equalsIgnoreCase(result));
    Assert.assertNotNull(templateUtilContext.getContext().get("util"));
}
 
Example 7
Source File: BAMMediatorConfigContextTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetContext() throws Exception {
    API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
    api.setStatus(APIConstants.CREATED);
    api.setContextTemplate("/");
    PowerMockito.mockStatic(APIUtil.class);
    PowerMockito.when(APIUtil.isAnalyticsEnabled()).thenReturn(false);
    ConfigContext configcontext = new APIConfigContext(api);
    BAMMediatorConfigContext bamMediatorConfigContext = new BAMMediatorConfigContext(configcontext);
    Assert.assertFalse((Boolean) bamMediatorConfigContext.getContext().get("statsEnabled"));
    PowerMockito.when(APIUtil.isAnalyticsEnabled()).thenReturn(true);
    bamMediatorConfigContext = new BAMMediatorConfigContext(configcontext);
    Assert.assertTrue((Boolean) bamMediatorConfigContext.getContext().get("statsEnabled"));
}
 
Example 8
Source File: SecurityConfigContextTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void testSecurityConfigContextPerEndpointSandbox() throws Exception {

    String json = "{\"endpoint_security\":{\n" +
            "  \"sandbox\":{\n" +
            "    \"enabled\":true,\n" +
            "    \"type\":\"DIGEST\",\n" +
            "    \"username\":\"admin\",\n" +
            "    \"password\":\"admin123#QA\"\n" +
            "  }\n" +
            "  }\n" +
            "}";
    API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
    api.setStatus(APIConstants.CREATED);
    api.setContextTemplate("/");
    api.setTransports(Constants.TRANSPORT_HTTP);
    api.setEndpointConfig(json);
    ConfigContext configcontext = new APIConfigContext(api);
    Mockito.when(apiManagerConfiguration.getFirstProperty(APIConstants.API_SECUREVAULT_ENABLE)).thenReturn("true");
    SecurityConfigContext securityConfigContext =
            new SecurityConfigContextWrapper(configcontext, api, apiManagerConfiguration);
    securityConfigContext.validate();
    VelocityContext velocityContext = securityConfigContext.getContext();
    Assert.assertNotNull(velocityContext.get("endpoint_security"));
    Map<String, EndpointSecurityModel> endpointSecurityModelMap =
            (Map<String, EndpointSecurityModel>) velocityContext.get("endpoint_security");
    EndpointSecurityModel sandbox = endpointSecurityModelMap.get("sandbox");
    Assert.assertTrue("Property enabled cannot be false.", sandbox.isEnabled());
    Assert.assertTrue("Property type cannot be other.", sandbox.getType().equalsIgnoreCase("digest"));
    Assert.assertTrue("Property username does not match.", "admin".equals(sandbox.getUsername()));
    Assert.assertTrue("Property base64value does not match. ",
            new String(Base64.encodeBase64("admin:admin123#QA".getBytes()))
                    .equalsIgnoreCase(sandbox.getBase64EncodedPassword()));
    Assert.assertTrue("Property securevault_alias does not match.",
            "admin--TestAPI1.0.0--sandbox".equalsIgnoreCase(sandbox.getAlias()));
    Assert.assertTrue("Property isSecureVaultEnabled cannot be false. ",
            velocityContext.get("isSecureVaultEnabled").equals(true));
    EndpointSecurityModel production = endpointSecurityModelMap.get("production");
    Assert.assertFalse("Property enabled cannot be true.", production.isEnabled());
}
 
Example 9
Source File: SecurityConfigContextTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void testSecurityConfigContext() throws Exception {

    API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
    api.setStatus(APIConstants.CREATED);
    api.setContextTemplate("/");
    api.setTransports(Constants.TRANSPORT_HTTP);
    api.setEndpointUTUsername("admin");
    api.setEndpointUTPassword("admin123");
    api.setEndpointSecured(true);
    api.setEndpointAuthDigest(true);
    ConfigContext configcontext = new APIConfigContext(api);
    Mockito.when(apiManagerConfiguration.getFirstProperty(APIConstants.API_SECUREVAULT_ENABLE)).thenReturn("true");
    SecurityConfigContext securityConfigContext =
            new SecurityConfigContextWrapper(configcontext, api, apiManagerConfiguration);
    securityConfigContext.validate();
    VelocityContext velocityContext = securityConfigContext.getContext();
    Assert.assertNotNull(velocityContext.get("endpoint_security"));
    Map<String, EndpointSecurityModel> endpointSecurityModelMap =
            (Map<String, EndpointSecurityModel>) velocityContext.get("endpoint_security");
    for (Map.Entry<String, EndpointSecurityModel> endpointSecurityModelEntry : endpointSecurityModelMap
            .entrySet()) {
        Assert.assertTrue("Property isEndpointSecured cannot be false.",
                endpointSecurityModelEntry.getValue().isEnabled());
        Assert.assertTrue("Property isEndpointAuthDigest cannot be false.",
                endpointSecurityModelEntry.getValue().getType().contains("digest"));
        Assert.assertTrue("Property username does not match.",
                "admin".equals(endpointSecurityModelEntry.getValue().getUsername()));
        Assert.assertTrue("Property base64unpw does not match. ",
                new String(Base64.encodeBase64("admin:admin123".getBytes()))
                        .equalsIgnoreCase(endpointSecurityModelEntry.getValue().getBase64EncodedPassword()));
        Assert.assertTrue("Property securevault_alias does not match.",
                "admin--TestAPI1.0.0".equalsIgnoreCase(endpointSecurityModelEntry.getValue().getAlias()));
    }
    Assert.assertTrue("Property isSecureVaultEnabled cannot be false. ",
            velocityContext.get("isSecureVaultEnabled").equals(true));
}
 
Example 10
Source File: JwtConfigContextTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void testJwtConfigContext() throws Exception {
    API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
    api.setStatus(APIConstants.CREATED);
    api.setContextTemplate("/");
    ConfigContext configcontext = new APIConfigContext(api);
    JwtConfigContext jwtConfigContext = new JwtConfigContext(configcontext);
    Assert.assertNotNull(jwtConfigContext.getContext());
}
 
Example 11
Source File: APIConfigContextTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetContext() throws Exception {
    API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
    api.setStatus(APIConstants.BLOCKED);
    api.setContextTemplate("/");
    APIConfigContext configContext = new APIConfigContext(api);
    boolean isBlocked = (Boolean) configContext.getContext().get("apiIsBlocked");
    Assert.assertTrue(isBlocked);
}
 
Example 12
Source File: APIMgtDAOTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddAndGetApi() throws Exception{
    APIIdentifier apiIdentifier = new APIIdentifier("testAddAndGetApi",
            "testAddAndGetApi", "1.0.0");
    API api = new API(apiIdentifier);
    api.setContext("/testAddAndGetApi");
    api.setContextTemplate("/testAddAndGetApi/{version}");
    api.setUriTemplates(getUriTemplateSet());
    api.setScopes(getScopes());
    api.setStatus(APIConstants.PUBLISHED);
    api.setAsDefaultVersion(true);
    int apiID = apiMgtDAO.addAPI(api, -1234);
    apiMgtDAO.addURITemplates(apiID, api, -1234);
    apiMgtDAO.updateAPI(api);
    apiMgtDAO.updateURITemplates(api, -1234);
    Set<APIStore> apiStoreSet = new HashSet<APIStore>();
    APIStore apiStore = new APIStore();
    apiStore.setDisplayName("wso2");
    apiStore.setEndpoint("http://localhost:9433/store");
    apiStore.setName("wso2");
    apiStore.setType("wso2");
    apiStoreSet.add(apiStore);
    apiMgtDAO.addExternalAPIStoresDetails(apiIdentifier,apiStoreSet);
    assertTrue(apiMgtDAO.getExternalAPIStoresDetails(apiIdentifier).size()>0);
    apiMgtDAO.deleteExternalAPIStoresDetails(apiIdentifier, apiStoreSet);
    apiMgtDAO.updateExternalAPIStoresDetails(apiIdentifier, Collections.<APIStore>emptySet());
    assertTrue(apiMgtDAO.getExternalAPIStoresDetails(apiIdentifier).size()==0);
    apiMgtDAO.deleteAPI(apiIdentifier);
}
 
Example 13
Source File: EndpointConfigContextTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test (expected = APITemplateException.class)
public void testEndpointConfigContext() throws Exception {

    API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
    api.setStatus(APIConstants.CREATED);
    api.setContextTemplate("/");
    String url = "http://maps.googleapis.com/maps/api/geocode/json?address=Colombo";
    String endpointConfig = "{\"production_endpoints\":{\"url\":\"" + url + "\", \"config\":null}," +
            "\"sandbox_endpoint\":{\"url\":\"" + url + "\",\"config\":null},\"endpoint_type\":\"http\"}";
    api.setEndpointConfig(endpointConfig);
    api.setUrl(url);
    api.setSandboxUrl(url);
    ConfigContext configcontext = new APIConfigContext(api);
    EndpointConfigContext endpointConfigContext = new EndpointConfigContext(configcontext, api);
    endpointConfigContext.validate();
    Assert.assertNotNull(endpointConfigContext.getContext().get("endpoint_config"));
    //set an empty string and check the validation
    endpointConfig = "";
    api.setEndpointConfig(endpointConfig);
    endpointConfigContext = new EndpointConfigContext(configcontext, api);
    endpointConfigContext.validate();
    //set a null value and check the validation
    endpointConfig = null;
    api.setEndpointConfig(endpointConfig);
    endpointConfigContext = new EndpointConfigContext(configcontext, api);
    endpointConfigContext.validate();
    //set invalid value and check the validation
    String invalidEndpointConfig = "\"production_endpoints\"{\"url\":\"" + url + "\", \"config\":null}," +
            "\"sandbox_endpoint\":{\"url\":\"" + url + "\",\"config\":null},\"endpoint_type\":\"http\"";
    api.setEndpointConfig(invalidEndpointConfig);
    endpointConfigContext = new EndpointConfigContext(configcontext, api);
    endpointConfigContext.validate();
}
 
Example 14
Source File: OAS2Parser.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
/**
 * This method returns api that is attached with api extensions related to micro-gw
 *
 * @param apiDefinition                  String
 * @param api                            API
 * @param isBasepathExtractedFromSwagger boolean
 * @return API
 */
@Override
public API setExtensionsToAPI(String apiDefinition, API api, boolean isBasepathExtractedFromSwagger) throws APIManagementException {
    Swagger swagger = getSwagger(apiDefinition);
    Map<String, Object> extensions = swagger.getVendorExtensions();
    if (extensions == null) {
        return api;
    }

    //Setup Custom auth header for API
    String authHeader = OASParserUtil.getAuthorizationHeaderFromSwagger(extensions);
    if (StringUtils.isNotBlank(authHeader)) {
        api.setAuthorizationHeader(authHeader);
    }
    //Setup mutualSSL configuration
    String mutualSSL = OASParserUtil.getMutualSSLEnabledFromSwagger(extensions);
    if (StringUtils.isNotBlank(mutualSSL)) {
        String securityList = api.getApiSecurity();
        if (StringUtils.isBlank(securityList)) {
            securityList = APIConstants.DEFAULT_API_SECURITY_OAUTH2;
        }
        if (APIConstants.OPTIONAL.equals(mutualSSL)) {
            securityList = securityList + "," + APIConstants.API_SECURITY_MUTUAL_SSL;
        } else if (APIConstants.MANDATORY.equals(mutualSSL)) {
            securityList = securityList + "," + APIConstants.API_SECURITY_MUTUAL_SSL_MANDATORY;
        }
        api.setApiSecurity(securityList);
    }
    //Setup CORSConfigurations
    CORSConfiguration corsConfiguration = OASParserUtil.getCorsConfigFromSwagger(extensions);
    if (corsConfiguration != null) {
        api.setCorsConfiguration(corsConfiguration);
    }
    //Setup Response cache enabling
    boolean responseCacheEnable = OASParserUtil.getResponseCacheFromSwagger(extensions);
    if (responseCacheEnable) {
        api.setResponseCache(APIConstants.ENABLED);
    }
    //Setup cache timeOut
    int cacheTimeOut = OASParserUtil.getCacheTimeOutFromSwagger(extensions);
    if (cacheTimeOut != 0) {
        api.setCacheTimeout(cacheTimeOut);
    }
    //Setup Transports
    String transports = OASParserUtil.getTransportsFromSwagger(extensions);
    if (StringUtils.isNotBlank(transports)) {
        api.setTransports(transports);
    }
    //Setup Throttlingtiers
    String throttleTier = OASParserUtil.getThrottleTierFromSwagger(extensions);
    if (StringUtils.isNotBlank(throttleTier)) {
        api.setApiLevelPolicy(throttleTier);
    }
    //Setup Basepath
    String basePath = OASParserUtil.getBasePathFromSwagger(extensions);
    if (StringUtils.isNotBlank(basePath) && isBasepathExtractedFromSwagger) {
        basePath = basePath.replace("{version}", api.getId().getVersion());
        api.setContextTemplate(basePath);
        api.setContext(basePath);
    }
    return api;
}
 
Example 15
Source File: APIMgtDAOTest.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
@Test
public void testAddUpdateDeleteBlockCondition() throws Exception {
    Subscriber subscriber = new Subscriber("blockuser1");
    subscriber.setTenantId(-1234);
    subscriber.setEmail("[email protected]");
    subscriber.setSubscribedDate(new Date(System.currentTimeMillis()));
    apiMgtDAO.addSubscriber(subscriber, null);
    Policy applicationPolicy = getApplicationPolicy("testAddUpdateDeleteBlockCondition");
    applicationPolicy.setTenantId(-1234);
    apiMgtDAO.addApplicationPolicy((ApplicationPolicy) applicationPolicy);
    Application application = new Application("testAddUpdateDeleteBlockCondition", subscriber);
    application.setTier("testAddUpdateDeleteBlockCondition");
    application.setId(apiMgtDAO.addApplication(application, "blockuser1"));
    APIIdentifier apiId = new APIIdentifier("testAddUpdateDeleteBlockCondition",
            "testAddUpdateDeleteBlockCondition", "1.0.0");
    API api = new API(apiId);
    api.setContext("/testAddUpdateDeleteBlockCondition");
    api.setContextTemplate("/testAddUpdateDeleteBlockCondition/{version}");
    apiMgtDAO.addAPI(api, -1234);
    BlockConditionsDTO apiBlockConditionDto = new BlockConditionsDTO();
    apiBlockConditionDto.setConditionValue("/testAddUpdateDeleteBlockCondition");
    apiBlockConditionDto.setConditionType(APIConstants.BLOCKING_CONDITIONS_API);
    apiBlockConditionDto.setUUID(UUID.randomUUID().toString());
    apiBlockConditionDto.setTenantDomain("carbon.super");
    BlockConditionsDTO apiUUID = apiMgtDAO.addBlockConditions(apiBlockConditionDto);
    BlockConditionsDTO applicationBlockCondition = new BlockConditionsDTO();
    applicationBlockCondition.setConditionValue("blockuser1:testAddUpdateDeleteBlockCondition");
    applicationBlockCondition.setConditionType(APIConstants.BLOCKING_CONDITIONS_APPLICATION);
    applicationBlockCondition.setUUID(UUID.randomUUID().toString());
    applicationBlockCondition.setTenantDomain("carbon.super");
    BlockConditionsDTO applicationUUID = apiMgtDAO.addBlockConditions(applicationBlockCondition);
    assertNotNull(applicationUUID);
    BlockConditionsDTO ipBlockcondition = new BlockConditionsDTO();
    ipBlockcondition.setConditionValue("127.0.0.1");
    ipBlockcondition.setConditionType(APIConstants.BLOCKING_CONDITIONS_IP);
    ipBlockcondition.setUUID(UUID.randomUUID().toString());
    ipBlockcondition.setTenantDomain("carbon.super");
    BlockConditionsDTO ipUUID = apiMgtDAO.addBlockConditions(ipBlockcondition);
    assertNotNull(ipUUID);
    BlockConditionsDTO userBlockcondition = new BlockConditionsDTO();
    userBlockcondition.setConditionValue("admin");
    userBlockcondition.setConditionType(APIConstants.BLOCKING_CONDITIONS_USER);
    userBlockcondition.setUUID(UUID.randomUUID().toString());
    userBlockcondition.setTenantDomain("carbon.super");
    BlockConditionsDTO userUUID = apiMgtDAO.addBlockConditions(userBlockcondition);
    assertNotNull(apiMgtDAO.getBlockConditionByUUID(apiUUID.getUUID()));
    assertNotNull(userUUID);
    assertNotNull(apiMgtDAO
            .updateBlockConditionState(apiMgtDAO.getBlockConditionByUUID(userUUID.getUUID()).getConditionId(),
                    "FALSE"));
    assertNotNull(apiMgtDAO.updateBlockConditionStateByUUID(userUUID.getUUID(), "FALSE"));
    apiMgtDAO.deleteBlockCondition(apiMgtDAO.getBlockConditionByUUID(userUUID.getUUID()).getConditionId());
    apiMgtDAO.getBlockCondition(apiMgtDAO.getBlockConditionByUUID(ipUUID.getUUID()).getConditionId());

    List<BlockConditionsDTO> blockConditions = apiMgtDAO.getBlockConditions("carbon.super");
    for (BlockConditionsDTO blockConditionsDTO : blockConditions) {
        apiMgtDAO.deleteBlockConditionByUUID(blockConditionsDTO.getUUID());
    }
    apiMgtDAO.deleteApplication(application);
    apiMgtDAO.removeThrottlePolicy(PolicyConstants.POLICY_LEVEL_APP, applicationPolicy.getPolicyName(), -1234);
    apiMgtDAO.deleteAPI(apiId);
    deleteSubscriber(subscriber.getId());
}
 
Example 16
Source File: APIMgtDAOTest.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
@Test
public void testCreateApplicationRegistrationEntry() throws Exception {
    Subscriber subscriber = new Subscriber("testCreateApplicationRegistrationEntry");
    subscriber.setTenantId(-1234);
    subscriber.setEmail("[email protected]");
    subscriber.setSubscribedDate(new Date(System.currentTimeMillis()));
    apiMgtDAO.addSubscriber(subscriber, null);
    Policy applicationPolicy = getApplicationPolicy("testCreateApplicationRegistrationEntry");
    applicationPolicy.setTenantId(-1234);
    apiMgtDAO.addApplicationPolicy((ApplicationPolicy) applicationPolicy);
    Application application = new Application("testCreateApplicationRegistrationEntry", subscriber);
    application.setTier("testCreateApplicationRegistrationEntry");
    application.setId(apiMgtDAO.addApplication(application, "testCreateApplicationRegistrationEntry"));

    ApplicationRegistrationWorkflowDTO applicationRegistrationWorkflowDTO = new
            ApplicationRegistrationWorkflowDTO();
    applicationRegistrationWorkflowDTO.setApplication(application);
    applicationRegistrationWorkflowDTO.setKeyType("PRODUCTION");
    applicationRegistrationWorkflowDTO.setDomainList("*");
    applicationRegistrationWorkflowDTO.setWorkflowReference(UUID.randomUUID().toString());
    applicationRegistrationWorkflowDTO.setValidityTime(100L);
    applicationRegistrationWorkflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());
    applicationRegistrationWorkflowDTO.setStatus(WorkflowStatus.CREATED);
    applicationRegistrationWorkflowDTO.setKeyManager("Default");
    apiMgtDAO.addWorkflowEntry(applicationRegistrationWorkflowDTO);
    OAuthAppRequest oAuthAppRequest = new OAuthAppRequest();
    OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo();
    oAuthApplicationInfo.setJsonString("");
    oAuthApplicationInfo.addParameter("tokenScope", "deafault");
    oAuthAppRequest.setOAuthApplicationInfo(oAuthApplicationInfo);
    applicationRegistrationWorkflowDTO.setAppInfoDTO(oAuthAppRequest);
    APIIdentifier apiId = new APIIdentifier("testCreateApplicationRegistrationEntry",
            "testCreateApplicationRegistrationEntry", "1.0.0");
    API api = new API(apiId);
    api.setContext("/testCreateApplicationRegistrationEntry");
    api.setContextTemplate("/testCreateApplicationRegistrationEntry/{version}");
    apiMgtDAO.addAPI(api, -1234);
    APIIdentifier apiId1 = new APIIdentifier("testCreateApplicationRegistrationEntry1",
            "testCreateApplicationRegistrationEntry1", "1.0.0");
    API api1 = new API(apiId1);
    api1.setContext("/testCreateApplicationRegistrationEntry1");
    api1.setContextTemplate("/testCreateApplicationRegistrationEntry1/{version}");
    apiMgtDAO.addAPI(api1, -1234);
    apiMgtDAO.createApplicationRegistrationEntry(applicationRegistrationWorkflowDTO, false);
    ApplicationRegistrationWorkflowDTO retrievedApplicationRegistrationWorkflowDTO = new
            ApplicationRegistrationWorkflowDTO();
    retrievedApplicationRegistrationWorkflowDTO.setExternalWorkflowReference(applicationRegistrationWorkflowDTO
            .getExternalWorkflowReference());
    apiMgtDAO.populateAppRegistrationWorkflowDTO(retrievedApplicationRegistrationWorkflowDTO);
    ApiTypeWrapper apiTypeWrapper = new ApiTypeWrapper(api);
    ApiTypeWrapper apiTypeWrapper1 = new ApiTypeWrapper(api1);
    apiMgtDAO.addSubscription(apiTypeWrapper, application.getId(), APIConstants.SubscriptionStatus.ON_HOLD,subscriber.getName());
    int subsId = apiMgtDAO.addSubscription(apiTypeWrapper1, application.getId(),
            APIConstants.SubscriptionStatus.ON_HOLD, subscriber.getName());
    assertTrue(apiMgtDAO.isContextExist(api.getContext()));
    assertTrue(api.getContext().equals(apiMgtDAO.getAPIContext(apiId)));
    apiMgtDAO.removeSubscription(apiId, application.getId());
    apiMgtDAO.removeSubscriptionById(subsId);
    apiMgtDAO.deleteAPI(apiId);
    apiMgtDAO.deleteAPI(apiId1);
    assertNotNull(apiMgtDAO.getWorkflowReference(application.getName(), subscriber.getName()));
    applicationRegistrationWorkflowDTO.setStatus(WorkflowStatus.APPROVED);
    apiMgtDAO.updateWorkflowStatus(applicationRegistrationWorkflowDTO);
    assertNotNull(apiMgtDAO.retrieveWorkflow(applicationRegistrationWorkflowDTO.getExternalWorkflowReference
            ()));
    assertNotNull(apiMgtDAO.retrieveWorkflowFromInternalReference(applicationRegistrationWorkflowDTO
            .getWorkflowReference(), applicationRegistrationWorkflowDTO.getWorkflowType()));
    apiMgtDAO.removeWorkflowEntry(applicationRegistrationWorkflowDTO.getExternalWorkflowReference(),
            applicationRegistrationWorkflowDTO.getWorkflowType());
    apiMgtDAO.deleteApplicationKeyMappingByApplicationIdAndType(application.getId(),"PRODUCTION");
    apiMgtDAO.deleteApplicationRegistration(application.getId(), "PRODUCTION",
            APIConstants.KeyManager.DEFAULT_KEY_MANAGER);
    apiMgtDAO.deleteApplication(application);
    apiMgtDAO.removeThrottlePolicy(PolicyConstants.POLICY_LEVEL_APP, "testCreateApplicationRegistrationEntry",
            -1234);
    deleteSubscriber(subscriber.getId());
}
 
Example 17
Source File: SecurityConfigContextTest.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
@Test
public void testSecurityConfigContextPerEndpointBothType() throws Exception {

    String json = "{\"endpoint_security\":{\n" +
            "  \"production\":{\n" +
            "    \"enabled\":true,\n" +
            "    \"type\":\"BASIC\",\n" +
            "    \"username\":\"admin\",\n" +
            "    \"password\":\"admin123#QA\"\n" +
            "  },\n" +
            "  \"sandbox\":{\n" +
            "    \"enabled\":true,\n" +
            "    \"type\":\"DIGEST\",\n" +
            "    \"username\":\"admin\",\n" +
            "    \"password\":\"admin123\"\n" +
            "  }\n" +
            "  }\n" +
            "}";
    API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
    api.setStatus(APIConstants.CREATED);
    api.setContextTemplate("/");
    api.setTransports(Constants.TRANSPORT_HTTP);
    api.setEndpointConfig(json);
    ConfigContext configcontext = new APIConfigContext(api);
    Mockito.when(apiManagerConfiguration.getFirstProperty(APIConstants.API_SECUREVAULT_ENABLE)).thenReturn("true");
    SecurityConfigContext securityConfigContext =
            new SecurityConfigContextWrapper(configcontext, api, apiManagerConfiguration);
    securityConfigContext.validate();
    VelocityContext velocityContext = securityConfigContext.getContext();
    Assert.assertNotNull(velocityContext.get("endpoint_security"));
    Map<String, EndpointSecurityModel> endpointSecurityModelMap =
            (Map<String, EndpointSecurityModel>) velocityContext.get("endpoint_security");
    EndpointSecurityModel production = endpointSecurityModelMap.get("production");
    Assert.assertTrue("Property enabled cannot be false.", production.isEnabled());
    Assert.assertTrue("Property type cannot be other.", production.getType().equalsIgnoreCase("basic"));
    Assert.assertTrue("Property username does not match.", "admin".equals(production.getUsername()));
    Assert.assertTrue("Property base64value does not match. ",
            new String(Base64.encodeBase64("admin:admin123#QA".getBytes()))
                    .equalsIgnoreCase(production.getBase64EncodedPassword()));
    Assert.assertTrue("Property securevault_alias does not match.",
            "admin--TestAPI1.0.0--production".equalsIgnoreCase(production.getAlias()));
    EndpointSecurityModel sandbox = endpointSecurityModelMap.get("sandbox");
    Assert.assertTrue("Property enabled cannot be false.", sandbox.isEnabled());
    Assert.assertTrue("Property type cannot be other.", sandbox.getType().equalsIgnoreCase("digest"));
    Assert.assertTrue("Property username does not match.", "admin".equals(sandbox.getUsername()));
    Assert.assertTrue("Property base64value does not match. ",
            new String(Base64.encodeBase64("admin:admin123".getBytes()))
                    .equalsIgnoreCase(sandbox.getBase64EncodedPassword()));
    Assert.assertTrue("Property securevault_alias does not match.",
            "admin--TestAPI1.0.0--sandbox".equalsIgnoreCase(sandbox.getAlias()));
    Assert.assertTrue("Property isSecureVaultEnabled cannot be false. ",
            velocityContext.get("isSecureVaultEnabled").equals(true));
}
 
Example 18
Source File: APIMgtDAOTest.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
@Test
public void testValidateSubscriptionDetails() throws APIManagementException {

    Subscriber subscriber = new Subscriber("sub_user1");
    subscriber.setEmail("[email protected]");
    subscriber.setSubscribedDate(new Date());
    subscriber.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
    apiMgtDAO.addSubscriber(subscriber, null);

    Application application = new Application("APP-10", subscriber);
    int applicationId = apiMgtDAO.addApplication(application, subscriber.getName());

    APIIdentifier apiId = new APIIdentifier("provider1", "WSO2-Utils", "V1.0.0");
    apiId.setTier("T10");
    API api = new API(apiId);
    api.setContext("/wso2utils");
    api.setContextTemplate("/wso2utils/{version}");
    apiMgtDAO.addAPI(api, MultitenantConstants.SUPER_TENANT_ID);
    ApiTypeWrapper apiTypeWrapper = new ApiTypeWrapper(api);
    int subsId = apiMgtDAO.addSubscription(apiTypeWrapper, applicationId, "UNBLOCKED", "sub_user1");
    String[] apiDetail = apiMgtDAO.getAPIDetailsByContext("/wso2utils");
    assertTrue(apiDetail.length == 2);
    assertEquals(apiDetail[0], "WSO2-Utils");
    assertEquals(apiDetail[1], "provider1");
    String policyName = "T10";
    SubscriptionPolicy policy = (SubscriptionPolicy) getSubscriptionPolicy(policyName);
    policy.setRateLimitCount(20);
    policy.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
    policy.setMonetizationPlan(APIConstants.Monetization.FIXED_RATE);
    apiMgtDAO.addSubscriptionPolicy(policy);

    APIKeyValidationInfoDTO infoDTO = new APIKeyValidationInfoDTO();
    apiMgtDAO.createApplicationKeyTypeMappingForManualClients(APIConstants.API_KEY_TYPE_PRODUCTION, "APP-10",
            "sub_user1", "clientId1","Default");
    Map<String, String> consumerkeyByApplicationIdAndKeyType =
            apiMgtDAO.getConsumerkeyByApplicationIdAndKeyType(applicationId, APIConstants.API_KEY_TYPE_PRODUCTION);
    assertEquals(consumerkeyByApplicationIdAndKeyType.get("Default"), "clientId1");
    assertTrue(apiMgtDAO.isMappingExistsforConsumerKey("Default","clientId1"));
    boolean validation = apiMgtDAO.validateSubscriptionDetails("/wso2utils", "V1.0.0", "clientId1","Default",
            infoDTO);
    APIKeyValidationInfoDTO infoDTO1 = new APIKeyValidationInfoDTO();
    apiMgtDAO.validateSubscriptionDetails(infoDTO1, "/wso2utils", "V1.0.0", "clientId1", "Default", false);
    if (validation) {
        assertEquals(20, infoDTO.getSpikeArrestLimit());
    } else {
        assertTrue("Expected validation for subscription details - true, but found - " + validation, validation);
    }
    if (infoDTO1.isAuthorized()) {
        assertEquals(20, infoDTO1.getSpikeArrestLimit());
    } else {
        assertTrue("Expected validation for subscription details - true, but found - " + infoDTO1.isAuthorized(),
                infoDTO1.isAuthorized());
    }
    apiMgtDAO.updateSubscriptionStatus(subsId, APIConstants.SubscriptionStatus.BLOCKED);
    APIKeyValidationInfoDTO infoDtoForBlocked = new APIKeyValidationInfoDTO();
    assertFalse(apiMgtDAO.validateSubscriptionDetails("/wso2utils", "V1.0.0", "clientId1", "Default",
            infoDtoForBlocked));
    assertEquals(infoDtoForBlocked.getValidationStatus(), APIConstants.KeyValidationStatus.API_BLOCKED);
    APIKeyValidationInfoDTO infoDtoForBlocked1 = new APIKeyValidationInfoDTO();
    assertFalse(apiMgtDAO.validateSubscriptionDetails(infoDtoForBlocked1, "/wso2utils", "V1.0.0", "clientId1"
            ,"Default",false).isAuthorized());
    assertEquals(infoDtoForBlocked1.getValidationStatus(), APIConstants.KeyValidationStatus.API_BLOCKED);
    APIKeyValidationInfoDTO infoDtoForOnHold = new APIKeyValidationInfoDTO();
    apiMgtDAO.updateSubscriptionStatus(subsId, APIConstants.SubscriptionStatus.ON_HOLD);
    assertFalse(apiMgtDAO.validateSubscriptionDetails("/wso2utils", "V1.0.0", "clientId1", "Default",
            infoDtoForOnHold));
    assertEquals(infoDtoForOnHold.getValidationStatus(), APIConstants.KeyValidationStatus.SUBSCRIPTION_INACTIVE);
    APIKeyValidationInfoDTO infoDtoForOnHold1 = new APIKeyValidationInfoDTO();
    apiMgtDAO.updateSubscriptionStatus(subsId, APIConstants.SubscriptionStatus.ON_HOLD);
    assertFalse(apiMgtDAO.validateSubscriptionDetails(infoDtoForOnHold1, "/wso2utils", "V1.0.0", "clientId1",
            "Default",false).isAuthorized());
    assertEquals(infoDtoForOnHold1.getValidationStatus(), APIConstants.KeyValidationStatus.SUBSCRIPTION_INACTIVE);
    apiMgtDAO.updateSubscriptionStatus(subsId, APIConstants.SubscriptionStatus.REJECTED);
    APIKeyValidationInfoDTO infoDotForRejected = new APIKeyValidationInfoDTO();
    assertFalse(apiMgtDAO.validateSubscriptionDetails("/wso2utils", "V1.0.0", "clientId1","Default", infoDotForRejected));
    assertEquals(infoDotForRejected.getValidationStatus(), APIConstants.KeyValidationStatus.SUBSCRIPTION_INACTIVE);
    APIKeyValidationInfoDTO infoDotForRejected1 = new APIKeyValidationInfoDTO();
    assertFalse(apiMgtDAO.validateSubscriptionDetails(infoDotForRejected1, "/wso2utils", "V1.0.0", "clientId1",
            "Default",false).isAuthorized());
    assertEquals(infoDotForRejected1.getValidationStatus(), APIConstants.KeyValidationStatus.SUBSCRIPTION_INACTIVE);
    apiMgtDAO.updateSubscriptionStatus(subsId, APIConstants.SubscriptionStatus.PROD_ONLY_BLOCKED);
    APIKeyValidationInfoDTO infoDotForProdOnlyBlocked = new APIKeyValidationInfoDTO();
    assertFalse(apiMgtDAO.validateSubscriptionDetails("/wso2utils", "V1.0.0", "clientId1","Default",
            infoDotForProdOnlyBlocked));
    assertEquals(infoDotForProdOnlyBlocked.getValidationStatus(), APIConstants.KeyValidationStatus.API_BLOCKED);
    APIKeyValidationInfoDTO infoDotForProdOnlyBlocked1 = new APIKeyValidationInfoDTO();
    assertFalse(apiMgtDAO.validateSubscriptionDetails(infoDotForProdOnlyBlocked1, "/wso2utils", "V1.0.0",
            "clientId1", "Default",false).isAuthorized());
    assertEquals(infoDotForProdOnlyBlocked1.getValidationStatus(), APIConstants.KeyValidationStatus.API_BLOCKED);
}
 
Example 19
Source File: SecurityConfigContextTest.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
@Test
public void testSecurityConfigContextIgnoringEndpointConfig() throws Exception {

    String json = "{\"endpoint_security\":{\n" +
            "  \"sandbox\":{\n" +
            "    \"enabled\":true,\n" +
            "    \"type\":\"DIGEST\",\n" +
            "    \"username\":\"admin\",\n" +
            "    \"password\":\"admin123#QA\"\n" +
            "  }\n" +
            "  }\n" +
            "}";

    API api = new API(new APIIdentifier("admin", "TestAPI", "1.0.0"));
    api.setStatus(APIConstants.CREATED);
    api.setContextTemplate("/");
    api.setTransports(Constants.TRANSPORT_HTTP);
    api.setEndpointConfig(json);
    api.setEndpointUTUsername("admin");
    api.setEndpointUTPassword("admin123");
    api.setEndpointSecured(true);
    api.setEndpointAuthDigest(true);
    ConfigContext configcontext = new APIConfigContext(api);
    Mockito.when(apiManagerConfiguration.getFirstProperty(APIConstants.API_SECUREVAULT_ENABLE)).thenReturn("true");
    SecurityConfigContext securityConfigContext =
            new SecurityConfigContextWrapper(configcontext, api, apiManagerConfiguration);
    securityConfigContext.validate();
    VelocityContext velocityContext = securityConfigContext.getContext();
    Assert.assertNotNull(velocityContext.get("endpoint_security"));
    Map<String, EndpointSecurityModel> endpointSecurityModelMap =
            (Map<String, EndpointSecurityModel>) velocityContext.get("endpoint_security");
    for (Map.Entry<String, EndpointSecurityModel> endpointSecurityModelEntry : endpointSecurityModelMap
            .entrySet()) {
        Assert.assertTrue("Property isEndpointSecured cannot be false.",
                endpointSecurityModelEntry.getValue().isEnabled());
        Assert.assertTrue("Property isEndpointAuthDigest cannot be false.",
                endpointSecurityModelEntry.getValue().getType().contains("digest"));
        Assert.assertTrue("Property username does not match.",
                "admin".equals(endpointSecurityModelEntry.getValue().getUsername()));
        Assert.assertTrue("Property base64unpw does not match. ",
                new String(Base64.encodeBase64("admin:admin123".getBytes()))
                        .equalsIgnoreCase(endpointSecurityModelEntry.getValue().getBase64EncodedPassword()));
        Assert.assertTrue("Property securevault_alias does not match.",
                "admin--TestAPI1.0.0".equalsIgnoreCase(endpointSecurityModelEntry.getValue().getAlias()));
    }
    Assert.assertTrue("Property isSecureVaultEnabled cannot be false. ",
            velocityContext.get("isSecureVaultEnabled").equals(true));
}
 
Example 20
Source File: OAS3Parser.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
/**
 * This method returns api that is attached with api extensions related to micro-gw
 *
 * @param apiDefinition                  String
 * @param api                            API
 * @param isBasepathExtractedFromSwagger boolean
 * @return API
 */
@Override
public API setExtensionsToAPI(String apiDefinition, API api, boolean isBasepathExtractedFromSwagger) throws APIManagementException {
    OpenAPI openAPI = getOpenAPI(apiDefinition);
    Map<String, Object> extensions = openAPI.getExtensions();
    if (extensions == null) {
        return api;
    }

    //Setup Custom auth header for API
    String authHeader = OASParserUtil.getAuthorizationHeaderFromSwagger(extensions);
    if (StringUtils.isNotBlank(authHeader)) {
        api.setAuthorizationHeader(authHeader);
    }
    //Setup mutualSSL configuration
    String mutualSSL = OASParserUtil.getMutualSSLEnabledFromSwagger(extensions);
    if (StringUtils.isNotBlank(mutualSSL)) {
        String securityList = api.getApiSecurity();
        if (StringUtils.isBlank(securityList)) {
            securityList = APIConstants.DEFAULT_API_SECURITY_OAUTH2;
        }
        if (APIConstants.OPTIONAL.equals(mutualSSL)) {
            securityList = securityList + "," + APIConstants.API_SECURITY_MUTUAL_SSL;
        } else if (APIConstants.MANDATORY.equals(mutualSSL)) {
            securityList = securityList + "," + APIConstants.API_SECURITY_MUTUAL_SSL_MANDATORY;
        }
        api.setApiSecurity(securityList);
    }
    //Setup CORSConfigurations
    CORSConfiguration corsConfiguration = OASParserUtil.getCorsConfigFromSwagger(extensions);
    if (corsConfiguration != null) {
        api.setCorsConfiguration(corsConfiguration);
    }
    //Setup Response cache enabling
    boolean responseCacheEnable = OASParserUtil.getResponseCacheFromSwagger(extensions);
    if (responseCacheEnable) {
        api.setResponseCache(APIConstants.ENABLED);
    }
    //Setup cache timeOut
    int cacheTimeOut = OASParserUtil.getCacheTimeOutFromSwagger(extensions);
    if (cacheTimeOut != 0) {
        api.setCacheTimeout(cacheTimeOut);
    }
    //Setup Transports
    String transports = OASParserUtil.getTransportsFromSwagger(extensions);
    if (StringUtils.isNotBlank(transports)) {
        api.setTransports(transports);
    }
    //Setup Throttlingtiers
    String throttleTier = OASParserUtil.getThrottleTierFromSwagger(extensions);
    if (StringUtils.isNotBlank(throttleTier)) {
        api.setApiLevelPolicy(throttleTier);
    }
    //Setup Basepath
    String basePath = OASParserUtil.getBasePathFromSwagger(extensions);
    if (StringUtils.isNotBlank(basePath) && isBasepathExtractedFromSwagger) {
        basePath = basePath.replace("{version}", api.getId().getVersion());
        api.setContextTemplate(basePath);
        api.setContext(basePath);
    }
    return api;
}