Search in sources :

Example 11 with ResourceException

use of com.yahoo.athenz.instance.provider.ResourceException in project athenz by yahoo.

the class InstanceAWSProviderTest method testConfirmInstanceNoAccountId.

@Test
public void testConfirmInstanceNoAccountId() {
    MockInstanceAWSProvider provider = new MockInstanceAWSProvider();
    System.setProperty(InstanceAWSProvider.AWS_PROP_PUBLIC_CERT, "src/test/resources/aws_public.cert");
    provider.initialize("provider", "com.yahoo.athenz.instance.provider.impl.InstanceAWSProvider", null);
    InstanceConfirmation confirmation = new InstanceConfirmation().setAttestationData("{\"document\": \"document\",\"signature\": \"signature\",\"role\": \"athenz.service\"}").setDomain("athenz").setProvider("provider").setService("service");
    try {
        provider.confirmInstance(confirmation);
        fail();
    } catch (ResourceException ex) {
    }
}
Also used : InstanceConfirmation(com.yahoo.athenz.instance.provider.InstanceConfirmation) ResourceException(com.yahoo.athenz.instance.provider.ResourceException) Test(org.testng.annotations.Test)

Example 12 with ResourceException

use of com.yahoo.athenz.instance.provider.ResourceException in project athenz by yahoo.

the class InstanceAWSProviderTest method testError.

@Test
public void testError() {
    InstanceAWSProvider provider = new InstanceAWSProvider();
    ResourceException exc = provider.error("unable to access");
    assertEquals(exc.getCode(), 403);
    assertEquals(exc.getMessage(), "ResourceException (403): unable to access");
}
Also used : ResourceException(com.yahoo.athenz.instance.provider.ResourceException) Test(org.testng.annotations.Test)

Example 13 with ResourceException

use of com.yahoo.athenz.instance.provider.ResourceException in project athenz by yahoo.

the class InstanceAWSProviderTest method testRefreshInstanceNoAccountId.

@Test
public void testRefreshInstanceNoAccountId() {
    MockInstanceAWSProvider provider = new MockInstanceAWSProvider();
    System.setProperty(InstanceAWSProvider.AWS_PROP_PUBLIC_CERT, "src/test/resources/aws_public.cert");
    provider.initialize("provider", "com.yahoo.athenz.instance.provider.impl.InstanceAWSProvider", null);
    InstanceConfirmation confirmation = new InstanceConfirmation().setAttestationData("{\"document\": \"document\",\"signature\": \"signature\",\"role\": \"athenz.service\"}").setDomain("athenz").setProvider("provider").setService("service");
    try {
        provider.refreshInstance(confirmation);
        fail();
    } catch (ResourceException ex) {
    }
}
Also used : InstanceConfirmation(com.yahoo.athenz.instance.provider.InstanceConfirmation) ResourceException(com.yahoo.athenz.instance.provider.ResourceException) Test(org.testng.annotations.Test)

Example 14 with ResourceException

use of com.yahoo.athenz.instance.provider.ResourceException in project athenz by yahoo.

the class InstanceAWSProviderTest method testEmptyRefreshAttestationData.

@Test
public void testEmptyRefreshAttestationData() {
    InstanceAWSProvider provider = new InstanceAWSProvider();
    provider.initialize("provider", "com.yahoo.athenz.instance.provider.impl.InstanceAWSProvider", null);
    InstanceConfirmation confirmation = new InstanceConfirmation();
    try {
        provider.refreshInstance(confirmation);
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), ResourceException.NOT_FOUND);
    }
    confirmation.setAttestationData("");
    try {
        provider.refreshInstance(confirmation);
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), ResourceException.NOT_FOUND);
    }
}
Also used : InstanceConfirmation(com.yahoo.athenz.instance.provider.InstanceConfirmation) ResourceException(com.yahoo.athenz.instance.provider.ResourceException) Test(org.testng.annotations.Test)

Aggregations

ResourceException (com.yahoo.athenz.instance.provider.ResourceException)14 Test (org.testng.annotations.Test)14 InstanceConfirmation (com.yahoo.athenz.instance.provider.InstanceConfirmation)12 HashMap (java.util.HashMap)8 AWSSecurityTokenServiceClient (com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient)1