Search in sources :

Example 1 with InstanceProviderClient

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

the class InstanceHttpProvider method initialize.

@Override
public void initialize(String provider, String providerEndpoint, KeyStore keyStore) {
    ProviderHostnameVerifier hostnameVerifier = new ProviderHostnameVerifier(provider);
    int readTimeout = Integer.parseInt(System.getProperty(PROP_READ_TIMEOUT, "30000"));
    int connectTimeout = Integer.parseInt(System.getProperty(PROP_CONNECT_TIMEOUT, "30000"));
    client = new InstanceProviderClient(providerEndpoint, hostnameVerifier, connectTimeout, readTimeout);
}
Also used : ProviderHostnameVerifier(com.yahoo.athenz.instance.provider.ProviderHostnameVerifier) InstanceProviderClient(com.yahoo.athenz.instance.provider.InstanceProviderClient)

Example 2 with InstanceProviderClient

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

the class InstanceHttpProviderTest method testInstanceHttpProviderConfirmInstance.

@Test
public void testInstanceHttpProviderConfirmInstance() {
    InstanceHttpProvider provider = new InstanceHttpProvider();
    provider.initialize("provider", "https://localhost:4443/instance", null);
    InstanceProviderClient client = Mockito.mock(InstanceProviderClient.class);
    provider.client = client;
    InstanceConfirmation confirmation = new InstanceConfirmation().setAttestationData("data").setDomain("athenz").setProvider("provider").setService("service");
    Mockito.when(client.postInstanceConfirmation(confirmation)).thenReturn(confirmation);
    InstanceConfirmation result = provider.confirmInstance(confirmation);
    assertEquals(result.getAttestationData(), "data");
    assertEquals(result.getDomain(), "athenz");
    assertEquals(result.getProvider(), "provider");
    assertEquals(result.getService(), "service");
    provider.close();
}
Also used : InstanceConfirmation(com.yahoo.athenz.instance.provider.InstanceConfirmation) InstanceProviderClient(com.yahoo.athenz.instance.provider.InstanceProviderClient) Test(org.testng.annotations.Test)

Example 3 with InstanceProviderClient

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

the class InstanceHttpProviderTest method testInstanceHttpProviderRefreshInstance.

@Test
public void testInstanceHttpProviderRefreshInstance() {
    InstanceHttpProvider provider = new InstanceHttpProvider();
    provider.initialize("provider", "https://localhost:4443/instance", null);
    InstanceProviderClient client = Mockito.mock(InstanceProviderClient.class);
    provider.client = client;
    InstanceConfirmation confirmation = new InstanceConfirmation().setAttestationData("data").setDomain("athenz").setProvider("provider").setService("service");
    Mockito.when(client.postRefreshConfirmation(confirmation)).thenReturn(confirmation);
    InstanceConfirmation result = provider.refreshInstance(confirmation);
    assertEquals(result.getAttestationData(), "data");
    assertEquals(result.getDomain(), "athenz");
    assertEquals(result.getProvider(), "provider");
    assertEquals(result.getService(), "service");
    provider.close();
}
Also used : InstanceConfirmation(com.yahoo.athenz.instance.provider.InstanceConfirmation) InstanceProviderClient(com.yahoo.athenz.instance.provider.InstanceProviderClient) Test(org.testng.annotations.Test)

Aggregations

InstanceProviderClient (com.yahoo.athenz.instance.provider.InstanceProviderClient)3 InstanceConfirmation (com.yahoo.athenz.instance.provider.InstanceConfirmation)2 Test (org.testng.annotations.Test)2 ProviderHostnameVerifier (com.yahoo.athenz.instance.provider.ProviderHostnameVerifier)1