Search in sources :

Example 1 with CORSManagementServiceClientException

use of org.wso2.carbon.identity.cors.mgt.core.exception.CORSManagementServiceClientException in project carbon-identity-framework by wso2.

the class OriginTests method testNullHost.

@Test
public void testNullHost() {
    String uri = "http:///path/";
    Origin origin;
    try {
        origin = new Origin(new Origin(uri).toString());
        fail();
    } catch (CORSManagementServiceClientException e) {
        assertEquals(e.getMessage(), "Bad origin URI: Missing authority (host)");
    }
}
Also used : Origin(org.wso2.carbon.identity.cors.mgt.core.model.Origin) CORSManagementServiceClientException(org.wso2.carbon.identity.cors.mgt.core.exception.CORSManagementServiceClientException) Test(org.testng.annotations.Test)

Example 2 with CORSManagementServiceClientException

use of org.wso2.carbon.identity.cors.mgt.core.exception.CORSManagementServiceClientException in project carbon-identity-framework by wso2.

the class OriginTests method testOrigin.

@Test
public void testOrigin() throws CORSManagementServiceClientException {
    String uri = "http://example.com";
    Origin o = new Origin(uri);
    assertEquals(o.toString(), uri);
    assertEquals(o.hashCode(), uri.hashCode());
}
Also used : Origin(org.wso2.carbon.identity.cors.mgt.core.model.Origin) Test(org.testng.annotations.Test)

Example 3 with CORSManagementServiceClientException

use of org.wso2.carbon.identity.cors.mgt.core.exception.CORSManagementServiceClientException in project carbon-identity-framework by wso2.

the class OriginTests method testIPAddressHost.

@Test
public void testIPAddressHost() {
    String uri = "http://192.168.0.1:8080";
    Origin origin = null;
    try {
        origin = new Origin(new Origin(uri).toString());
    } catch (CORSManagementServiceClientException e) {
        fail(e.getMessage());
    }
    assertEquals(origin.toString(), uri);
    assertEquals(origin.getScheme(), "http");
    assertEquals(origin.getHost(), "192.168.0.1");
    assertEquals(origin.getPort(), 8080);
    assertEquals(origin.getSuffix(), "192.168.0.1:8080");
}
Also used : Origin(org.wso2.carbon.identity.cors.mgt.core.model.Origin) CORSManagementServiceClientException(org.wso2.carbon.identity.cors.mgt.core.exception.CORSManagementServiceClientException) Test(org.testng.annotations.Test)

Example 4 with CORSManagementServiceClientException

use of org.wso2.carbon.identity.cors.mgt.core.exception.CORSManagementServiceClientException in project carbon-identity-framework by wso2.

the class OriginTests method testOriginInequality.

@Test
public void testOriginInequality() throws CORSManagementServiceClientException {
    String uri1 = "http://example.com";
    String uri2 = "HTTP://EXAMPLE.COM";
    Origin o1 = new Origin(uri1);
    Origin o2 = new Origin(uri2);
    assertNotEquals(o2, o1);
}
Also used : Origin(org.wso2.carbon.identity.cors.mgt.core.model.Origin) Test(org.testng.annotations.Test)

Example 5 with CORSManagementServiceClientException

use of org.wso2.carbon.identity.cors.mgt.core.exception.CORSManagementServiceClientException in project carbon-identity-framework by wso2.

the class OriginTests method testValidation.

@Test
public void testValidation() {
    String uri = "http://example.com";
    Origin origin = null;
    try {
        origin = new Origin(uri);
    } catch (CORSManagementServiceClientException e) {
        fail(e.getMessage());
    }
    assertNotNull(origin);
    assertEquals(origin.toString(), uri);
}
Also used : Origin(org.wso2.carbon.identity.cors.mgt.core.model.Origin) CORSManagementServiceClientException(org.wso2.carbon.identity.cors.mgt.core.exception.CORSManagementServiceClientException) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)10 CORSManagementServiceClientException (org.wso2.carbon.identity.cors.mgt.core.exception.CORSManagementServiceClientException)10 Origin (org.wso2.carbon.identity.cors.mgt.core.model.Origin)10 Response (javax.ws.rs.core.Response)2 APIError (org.wso2.carbon.identity.api.server.common.error.APIError)2 ErrorResponse (org.wso2.carbon.identity.api.server.common.error.ErrorResponse)2 CORSManagementServiceServerException (org.wso2.carbon.identity.cors.mgt.core.exception.CORSManagementServiceServerException)2 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)1 CORSManagementService (org.wso2.carbon.identity.cors.mgt.core.CORSManagementService)1 CORSManagementServiceException (org.wso2.carbon.identity.cors.mgt.core.exception.CORSManagementServiceException)1 CORSOrigin (org.wso2.carbon.identity.cors.mgt.core.model.CORSOrigin)1