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));
}
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");
}
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));
}
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));
}
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");
}
Aggregations