Search in sources :

Example 6 with Struct

use of com.yahoo.rdl.Struct 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 7 with Struct

use of com.yahoo.rdl.Struct 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 8 with Struct

use of com.yahoo.rdl.Struct in project athenz by yahoo.

the class SSHRequest method getSshKeyReqType.

String getSshKeyReqType() {
    Struct keyReq = JSON.fromString(ssh, Struct.class);
    if (keyReq == null) {
        LOGGER.error("getSshKeyReqType: Unable to parse ssh key req: " + ssh);
        return null;
    }
    String sshType = keyReq.getString(ZTSConsts.ZTS_SSH_TYPE);
    if (sshType == null) {
        LOGGER.error("getSshKeyReqType: SSH Key request does not have certtype: " + ssh);
    }
    return sshType;
}
Also used : Struct(com.yahoo.rdl.Struct)

Example 9 with Struct

use of com.yahoo.rdl.Struct in project athenz by yahoo.

the class ZMSImplTest method createEntityObject.

private Entity createEntityObject(String entityName) {
    Entity entity = new Entity();
    entity.setName(entityName);
    Struct value = new Struct();
    value.put("Key1", "Value1");
    entity.setValue(value);
    return entity;
}
Also used : Struct(com.yahoo.rdl.Struct)

Example 10 with Struct

use of com.yahoo.rdl.Struct in project athenz by yahoo.

the class ZMSImplTest method testPutEntityAuthzDetails.

@Test
public void testPutEntityAuthzDetails() throws JsonProcessingException {
    final String name = "zts.authorization_details_setup";
    final String domainName = "put-entity-authz-details";
    Entity entity = new Entity();
    entity.setName(ResourceUtils.entityResourceName(domainName, name));
    final String jsonData = "{\"type\":\"message_access\",\"roles\":[{\"name\":\"msg-readers\"," + "\"optional\":true},{\"name\":\"msg-writers\",\"optional\":false},{\"name\":" + "\"msg-editors\"}],\"fields\":[{\"name\":\"location\",\"optional\":true}," + "{\"name\":\"identifier\",\"optional\":false},{\"name\":\"resource\"}]}";
    entity.setValue(new Struct().with("data", jsonData));
    TopLevelDomain dom1 = zmsTestInitializer.createTopLevelDomainObject(domainName, "Test Domain1", "testOrg", zmsTestInitializer.getAdminUser());
    zmsTestInitializer.getZms().postTopLevelDomain(zmsTestInitializer.getMockDomRsrcCtx(), zmsTestInitializer.getAuditRef(), dom1);
    // add a new authz entity as expected
    zmsTestInitializer.getZms().putEntity(zmsTestInitializer.getMockDomRsrcCtx(), domainName, name, zmsTestInitializer.getAuditRef(), entity);
    Entity response = zmsTestInitializer.getZms().getEntity(zmsTestInitializer.getMockDomRsrcCtx(), domainName, name);
    assertNotNull(response);
    ObjectMapper jsonMapper = new ObjectMapper();
    jsonMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
    AuthzDetailsEntity authzEntity = AuthzHelper.convertEntityToAuthzDetailsEntity(response);
    assertNotNull(authzEntity);
    List<AuthzDetailsField> roles = authzEntity.getRoles();
    assertNotNull(roles);
    assertEquals(roles.size(), 3);
    List<AuthzDetailsField> fields = authzEntity.getFields();
    assertNotNull(fields);
    assertEquals(fields.size(), 3);
    zmsTestInitializer.getZms().deleteTopLevelDomain(zmsTestInitializer.getMockDomRsrcCtx(), domainName, zmsTestInitializer.getAuditRef());
}
Also used : AuthzDetailsEntity(com.yahoo.athenz.common.config.AuthzDetailsEntity) AuthzDetailsEntity(com.yahoo.athenz.common.config.AuthzDetailsEntity) AuthzDetailsField(com.yahoo.athenz.common.config.AuthzDetailsField) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Struct(com.yahoo.rdl.Struct)

Aggregations

Struct (com.yahoo.rdl.Struct)61 Test (org.testng.annotations.Test)30 Array (com.yahoo.rdl.Array)10 ZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore)7 AuthzDetailsEntity (com.yahoo.athenz.common.config.AuthzDetailsEntity)5 Path (java.nio.file.Path)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Assertion (com.yahoo.athenz.zms.Assertion)3 Policy (com.yahoo.athenz.zms.Policy)3 ZpeMatch (com.yahoo.athenz.zpe.match.ZpeMatch)3 File (java.io.File)3 AuthzDetailsField (com.yahoo.athenz.common.config.AuthzDetailsField)2 FilesHelper (com.yahoo.athenz.common.server.util.FilesHelper)2 PublicKeyEntry (com.yahoo.athenz.zms.PublicKeyEntry)2 ServiceIdentity (com.yahoo.athenz.zms.ServiceIdentity)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 BasicSessionCredentials (com.amazonaws.auth.BasicSessionCredentials)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 AthenzConfig (com.yahoo.athenz.common.config.AthenzConfig)1