Search in sources :

Example 6 with DomainMetaStore

use of com.yahoo.athenz.common.server.metastore.DomainMetaStore in project athenz by yahoo.

the class ZMSImplTest method testGetDomainMetaStoreValidValuesList.

@Test
public void testGetDomainMetaStoreValidValuesList() {
    DomainMetaStore savedMetaStore = zmsTestInitializer.getZms().domainMetaStore;
    DomainMetaStore mockDomainMetaStore = Mockito.mock(DomainMetaStore.class);
    List<String> awsAccountsList = Collections.singletonList("awsAcc");
    when(mockDomainMetaStore.getValidAWSAccounts(isNull())).thenReturn(awsAccountsList);
    List<String> businessServicesList = Collections.singletonList("bservice");
    when(mockDomainMetaStore.getValidBusinessServices(isNull())).thenReturn(businessServicesList);
    List<String> azureList = Collections.singletonList("azureSub");
    when(mockDomainMetaStore.getValidAzureSubscriptions(isNull())).thenReturn(azureList);
    List<String> productIdList = Collections.singletonList("product");
    when(mockDomainMetaStore.getValidProductIds(isNull())).thenReturn(productIdList);
    zmsTestInitializer.getZms().domainMetaStore = mockDomainMetaStore;
    assertEquals("bservice", zmsTestInitializer.getZms().getDomainMetaStoreValidValuesList(zmsTestInitializer.getMockDomRsrcCtx(), "businessService", null).getValidValues().get(0));
    assertEquals("awsAcc", zmsTestInitializer.getZms().getDomainMetaStoreValidValuesList(zmsTestInitializer.getMockDomRsrcCtx(), "awsAccount", null).getValidValues().get(0));
    assertEquals("azureSub", zmsTestInitializer.getZms().getDomainMetaStoreValidValuesList(zmsTestInitializer.getMockDomRsrcCtx(), "azureSubscription", null).getValidValues().get(0));
    assertEquals("product", zmsTestInitializer.getZms().getDomainMetaStoreValidValuesList(zmsTestInitializer.getMockDomRsrcCtx(), "productId", null).getValidValues().get(0));
    zmsTestInitializer.getZms().domainMetaStore = savedMetaStore;
}
Also used : DomainMetaStore(com.yahoo.athenz.common.server.metastore.DomainMetaStore)

Example 7 with DomainMetaStore

use of com.yahoo.athenz.common.server.metastore.DomainMetaStore in project athenz by yahoo.

the class ZMSImplTest method testGetDomainMetaStoreValidValuesListEmpty.

@Test
public void testGetDomainMetaStoreValidValuesListEmpty() {
    DomainMetaStore savedMetaStore = zmsTestInitializer.getZms().domainMetaStore;
    zmsTestInitializer.getZms().domainMetaStore = new TestDomainMetaStore();
    DomainMetaStoreValidValuesList emptyValidValuesList = new DomainMetaStoreValidValuesList();
    emptyValidValuesList.setValidValues(new ArrayList<>());
    assertEquals(emptyValidValuesList, zmsTestInitializer.getZms().getDomainMetaStoreValidValuesList(zmsTestInitializer.getMockDomRsrcCtx(), "businessService", null));
    assertEquals(emptyValidValuesList, zmsTestInitializer.getZms().getDomainMetaStoreValidValuesList(zmsTestInitializer.getMockDomRsrcCtx(), "awsAccount", null));
    assertEquals(emptyValidValuesList, zmsTestInitializer.getZms().getDomainMetaStoreValidValuesList(zmsTestInitializer.getMockDomRsrcCtx(), "azureSubscription", null));
    assertEquals(emptyValidValuesList, zmsTestInitializer.getZms().getDomainMetaStoreValidValuesList(zmsTestInitializer.getMockDomRsrcCtx(), "productId", null));
    zmsTestInitializer.getZms().domainMetaStore = savedMetaStore;
}
Also used : DomainMetaStore(com.yahoo.athenz.common.server.metastore.DomainMetaStore)

Example 8 with DomainMetaStore

use of com.yahoo.athenz.common.server.metastore.DomainMetaStore in project athenz by yahoo.

the class ZMSImplTest method testGetDomainMetaStoreValidValuesListBadAttribute.

@Test
public void testGetDomainMetaStoreValidValuesListBadAttribute() {
    DomainMetaStore savedMetaStore = zmsTestInitializer.getZms().domainMetaStore;
    zmsTestInitializer.getZms().domainMetaStore = new TestDomainMetaStore();
    try {
        zmsTestInitializer.getZms().getDomainMetaStoreValidValuesList(zmsTestInitializer.getMockDomRsrcCtx(), "badAttribute", null);
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getMessage(), "ResourceException (400): {code: 400, message: \"Invalid attribute: badAttribute\"}");
    } finally {
        zmsTestInitializer.getZms().domainMetaStore = savedMetaStore;
    }
}
Also used : DomainMetaStore(com.yahoo.athenz.common.server.metastore.DomainMetaStore)

Example 9 with DomainMetaStore

use of com.yahoo.athenz.common.server.metastore.DomainMetaStore in project athenz by yahoo.

the class ZMSImplTest method testPutDomainMetaIDomainMetaStoreException.

@Test
public void testPutDomainMetaIDomainMetaStoreException() {
    final String domainName = "athenz-domain-meta-with-exception";
    DomainMetaStore savedMetaStore = zmsTestInitializer.getZms().domainMetaStore;
    zmsTestInitializer.getZms().domainMetaStore = new TestDomainMetaStore();
    // value with exc- will throw an exception but we should
    // not reject the request
    TopLevelDomain dom1 = zmsTestInitializer.createTopLevelDomainObject(domainName, "Test Domain1", "testOrg", zmsTestInitializer.getAdminUser());
    dom1.setBusinessService("exc-business-service");
    zmsTestInitializer.getZms().postTopLevelDomain(zmsTestInitializer.getMockDomRsrcCtx(), zmsTestInitializer.getAuditRef(), dom1);
    Domain domain = zmsTestInitializer.getZms().getDomain(zmsTestInitializer.getMockDomRsrcCtx(), domainName);
    assertNotNull(domain);
    assertEquals(domain.getBusinessService(), "exc-business-service");
    // try with system attribute now as well
    DomainMeta meta = new DomainMeta().setAccount("exc-aws-account");
    zmsTestInitializer.getZms().putDomainSystemMeta(zmsTestInitializer.getMockDomRsrcCtx(), domainName, ZMSConsts.SYSTEM_META_ACCOUNT, zmsTestInitializer.getAuditRef(), meta);
    domain = zmsTestInitializer.getZms().getDomain(zmsTestInitializer.getMockDomRsrcCtx(), domainName);
    assertNotNull(domain);
    assertEquals(domain.getAccount(), "exc-aws-account");
    assertEquals(domain.getBusinessService(), "exc-business-service");
    zmsTestInitializer.getZms().deleteTopLevelDomain(zmsTestInitializer.getMockDomRsrcCtx(), domainName, zmsTestInitializer.getAuditRef());
    zmsTestInitializer.getZms().domainMetaStore = savedMetaStore;
}
Also used : AthenzDomain(com.yahoo.athenz.zms.store.AthenzDomain) DomainMetaStore(com.yahoo.athenz.common.server.metastore.DomainMetaStore)

Aggregations

DomainMetaStore (com.yahoo.athenz.common.server.metastore.DomainMetaStore)9 AthenzDomain (com.yahoo.athenz.zms.store.AthenzDomain)4