Search in sources :

Example 36 with ChangeLogStore

use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.

the class DataStoreTest method testProcessJWSDomainsNullList.

@Test
public void testProcessJWSDomainsNullList() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    store.jwsDomainSupport = true;
    assertTrue(store.processJWSDomains(null));
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 37 with ChangeLogStore

use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.

the class DataStoreTest method testGetPublicKeyUpdated.

@Test
public void testGetPublicKeyUpdated() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    store.publicKeyCache.put("coretech.storage_0", "PublicKey0");
    store.publicKeyCache.put("sports.storage_0", "PublicKey0");
    store.publicKeyCache.put("sports.storage_1", "PublicKey1");
    Map<String, String> addKeys = new HashMap<>();
    addKeys.put("coretech.storage_0", "PublicKey0");
    addKeys.put("sports.storage_0", "PublicKey100");
    addKeys.put("sports.storage_1", "PublicKey101");
    store.addPublicKeys(addKeys);
    assertEquals(store.getPublicKey("coretech", "storage", "0"), "PublicKey0");
    assertEquals(store.getPublicKey("sports", "storage", "0"), "PublicKey100");
    assertEquals(store.getPublicKey("sports", "storage", "1"), "PublicKey101");
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 38 with ChangeLogStore

use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.

the class DataStoreTest method testValidateJWSDomainMissingKid.

@Test
public void testValidateJWSDomainMissingKid() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    store.loadAthenzPublicKeys();
    JWSDomain jwsDomain = createJWSDomain("coretech", "weather", "0");
    final Base64.Encoder encoder = Base64.getUrlEncoder().withoutPadding();
    final String protectedHeader = "{\"alg\":\"SHA256\"}";
    jwsDomain.setProtectedHeader(encoder.encodeToString(protectedHeader.getBytes(StandardCharsets.UTF_8)));
    assertFalse(store.validateJWSDomain("coretech", jwsDomain));
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) Test(org.testng.annotations.Test)

Example 39 with ChangeLogStore

use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.

the class DataStoreTest method testGetInvalidCurveName.

@Test
public void testGetInvalidCurveName() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    ECParameterSpec spec = Mockito.mock(ECParameterSpec.class);
    when(spec.getCurve()).thenReturn(null);
    when(spec.getG()).thenReturn(null);
    when(spec.getH()).thenReturn(new BigInteger("100"));
    when(spec.getN()).thenReturn(new BigInteger("100"));
    assertNull(store.getCurveName(spec, false));
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) ECParameterSpec(org.bouncycastle.jce.spec.ECParameterSpec) BigInteger(java.math.BigInteger) Test(org.testng.annotations.Test)

Example 40 with ChangeLogStore

use of com.yahoo.athenz.common.server.store.ChangeLogStore in project athenz by yahoo.

the class DataStoreTest method testAddDomainToCacheNewDomain.

@Test
public void testAddDomainToCacheNewDomain() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null, ztsMetric);
    DataCache dataCache = new DataCache();
    Role role = new Role();
    role.setName("coretech:role.admin");
    List<RoleMember> members = new ArrayList<>();
    members.add(new RoleMember().setMemberName("user_domain.user"));
    role.setRoleMembers(members);
    List<Role> roles = new ArrayList<>();
    roles.add(role);
    DomainData domainData = new DomainData();
    domainData.setRoles(roles);
    dataCache.setDomainData(domainData);
    store.addDomainToCache("coretech", dataCache);
    DomainData domain = store.getDomainData("coretech");
    assertNotNull(domain);
    assertEquals(domain.getRoles().size(), 1);
    assertEquals(domain.getRoles().get(0).getName(), "coretech:role.admin");
    assertEquals(domain.getRoles().get(0).getRoleMembers().size(), 1);
    assertEquals(domain.getRoles().get(0).getRoleMembers().get(0).getMemberName(), "user_domain.user");
}
Also used : MemberRole(com.yahoo.athenz.zts.cache.MemberRole) ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) DataCache(com.yahoo.athenz.zts.cache.DataCache) Test(org.testng.annotations.Test)

Aggregations

ChangeLogStore (com.yahoo.athenz.common.server.store.ChangeLogStore)262 Test (org.testng.annotations.Test)258 MockZMSFileChangeLogStore (com.yahoo.athenz.zts.store.MockZMSFileChangeLogStore)107 ZMSFileChangeLogStore (com.yahoo.athenz.common.server.store.impl.ZMSFileChangeLogStore)106 DataStore (com.yahoo.athenz.zts.store.DataStore)106 Path (java.nio.file.Path)71 InstanceCertManager (com.yahoo.athenz.zts.cert.InstanceCertManager)57 DataCache (com.yahoo.athenz.zts.cache.DataCache)41 InstanceProvider (com.yahoo.athenz.instance.provider.InstanceProvider)40 X509Certificate (java.security.cert.X509Certificate)35 InstanceConfirmation (com.yahoo.athenz.instance.provider.InstanceConfirmation)34 MemberRole (com.yahoo.athenz.zts.cache.MemberRole)27 X509CertRecord (com.yahoo.athenz.common.server.cert.X509CertRecord)23 HttpServletRequest (javax.servlet.http.HttpServletRequest)21 HttpServletResponse (javax.servlet.http.HttpServletResponse)17 Response (javax.ws.rs.core.Response)17 Principal (com.yahoo.athenz.auth.Principal)16 MockStatusCheckerNoException (com.yahoo.athenz.zts.status.MockStatusCheckerNoException)12 File (java.io.File)12 IOException (java.io.IOException)12