Search in sources :

Example 6 with ZMSFileChangeLogStore

use of com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore in project athenz by yahoo.

the class ZMSFileChangeLogStoreTest method getExistent.

@Test
public void getExistent() {
    ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null);
    Struct data = new Struct();
    data.put("key", "val1");
    fstore.put("test1", JSON.bytes(data));
    Struct st = fstore.get("test1", Struct.class);
    assertNotNull(st);
    assertEquals(st.get("key"), "val1");
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) Struct(com.yahoo.rdl.Struct) Test(org.testng.annotations.Test)

Example 7 with ZMSFileChangeLogStore

use of com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore in project athenz by yahoo.

the class ZMSFileChangeLogStoreTest method scanDelete.

@Test
public void scanDelete() {
    ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null);
    Struct data = new Struct();
    data.put("key", "val1");
    fstore.put("test1", JSON.bytes(data));
    data = new Struct();
    data.put("key", "val1");
    fstore.put("test2", JSON.bytes(data));
    data = new Struct();
    data.put("key", "val1");
    fstore.put("test3", JSON.bytes(data));
    fstore.delete("test2");
    List<String> ls = fstore.scan();
    assertEquals(ls.size(), 2);
    assertTrue(ls.contains("test1"));
    assertTrue(ls.contains("test3"));
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) Struct(com.yahoo.rdl.Struct) Test(org.testng.annotations.Test)

Example 8 with ZMSFileChangeLogStore

use of com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore in project athenz by yahoo.

the class ZMSFileChangeLogStoreTest method scanMultiple.

@Test
public void scanMultiple() {
    ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null);
    Struct data = new Struct();
    data.put("key", "val1");
    fstore.put("test1", JSON.bytes(data));
    data = new Struct();
    data.put("key", "val1");
    fstore.put("test2", JSON.bytes(data));
    data = new Struct();
    data.put("key", "val1");
    fstore.put("test3", JSON.bytes(data));
    List<String> ls = fstore.scan();
    assertEquals(ls.size(), 3);
    assertTrue(ls.contains("test1"));
    assertTrue(ls.contains("test2"));
    assertTrue(ls.contains("test3"));
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) Struct(com.yahoo.rdl.Struct) Test(org.testng.annotations.Test)

Example 9 with ZMSFileChangeLogStore

use of com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore in project athenz by yahoo.

the class ZMSFileChangeLogStoreTest method getNonExistent.

@Test
public void getNonExistent() {
    ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null);
    Struct st = fstore.get("NotExistent", Struct.class);
    assertNull(st);
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) Struct(com.yahoo.rdl.Struct) Test(org.testng.annotations.Test)

Example 10 with ZMSFileChangeLogStore

use of com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore in project athenz by yahoo.

the class ZMSFileChangeLogStoreTest method getSignedDomainListOneBadDomain.

@Test
public void getSignedDomainListOneBadDomain() {
    ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null);
    ZMSClient zmsClient = Mockito.mock(ZMSClient.class);
    DomainData domData1 = new DomainData().setName("athenz");
    SignedDomain domain1 = new SignedDomain().setDomain(domData1);
    DomainData domData2 = new DomainData().setName("sports");
    SignedDomain domain2 = new SignedDomain().setDomain(domData2);
    List<SignedDomain> domains = new ArrayList<>();
    domains.add(domain1);
    domains.add(domain2);
    SignedDomains domainList = new SignedDomains().setDomains(domains);
    List<SignedDomain> mockDomains = new ArrayList<>();
    mockDomains.add(domain1);
    SignedDomains mockDomainList = new SignedDomains().setDomains(mockDomains);
    Mockito.when(zmsClient.getSignedDomains("athenz", null, null, null)).thenReturn(mockDomainList);
    Mockito.when(zmsClient.getSignedDomains("sports", null, null, null)).thenReturn(null);
    List<SignedDomain> returnList = fstore.getSignedDomainList(zmsClient, domainList);
    assertEquals(returnList.size(), 1);
    assertEquals(returnList.get(0).getDomain().getName(), "athenz");
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) DomainData(com.yahoo.athenz.zms.DomainData) SignedDomain(com.yahoo.athenz.zms.SignedDomain) ArrayList(java.util.ArrayList) SignedDomains(com.yahoo.athenz.zms.SignedDomains) ZMSClient(com.yahoo.athenz.zms.ZMSClient) Test(org.testng.annotations.Test)

Aggregations

ZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore)23 Test (org.testng.annotations.Test)23 SignedDomain (com.yahoo.athenz.zms.SignedDomain)11 SimplePrincipal (com.yahoo.athenz.auth.impl.SimplePrincipal)9 ChangeLogStore (com.yahoo.athenz.zts.store.ChangeLogStore)9 DataStore (com.yahoo.athenz.zts.store.DataStore)9 MockZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore)9 Struct (com.yahoo.rdl.Struct)7 Principal (com.yahoo.athenz.auth.Principal)6 AuditLogMsgBuilder (com.yahoo.athenz.common.server.log.AuditLogMsgBuilder)6 AuditLogger (com.yahoo.athenz.common.server.log.AuditLogger)6 DefaultAuditLogMsgBuilder (com.yahoo.athenz.common.server.log.impl.DefaultAuditLogMsgBuilder)6 DefaultAuditLogger (com.yahoo.athenz.common.server.log.impl.DefaultAuditLogger)6 HashSet (java.util.HashSet)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 CertificateAuthority (com.yahoo.athenz.auth.impl.CertificateAuthority)3 InstanceCertManager (com.yahoo.athenz.zts.cert.InstanceCertManager)3 X509CertRecord (com.yahoo.athenz.zts.cert.X509CertRecord)3 Path (java.nio.file.Path)3 X509Certificate (java.security.cert.X509Certificate)3