Search in sources :

Example 11 with Struct

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

the class PolicyUpdaterConfiguration method readZpuConfiguration.

private Struct readZpuConfiguration(String pathToFile) {
    LOG.info("Reading configuration file: {}", pathToFile);
    Struct conf = null;
    try {
        Path path = Paths.get(pathToFile);
        conf = JSON.fromBytes(Files.readAllBytes(path), Struct.class);
    } catch (Exception e) {
    }
    return conf;
}
Also used : Path(java.nio.file.Path) Struct(com.yahoo.rdl.Struct)

Example 12 with Struct

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

the class InstanceAWSECSProviderTest method testGetInstanceId.

@Test
public void testGetInstanceId() {
    InstanceAWSECSProvider provider = new InstanceAWSECSProvider();
    provider.initialize("provider", "com.yahoo.athenz.instance.provider.impl.InstanceAWSECSProvider", null, null);
    AWSAttestationData data = new AWSAttestationData();
    data.setTaskid("task1234");
    assertEquals(provider.getInstanceId(data, null, "id-1234"), "task1234");
    data.setTaskid(null);
    Struct doc = new Struct();
    doc.put(InstanceAWSProvider.ATTR_INSTANCE_ID, "data1234");
    assertEquals(provider.getInstanceId(data, doc, "data1234"), "data1234");
    data.setTaskid("");
    assertEquals(provider.getInstanceId(data, doc, "id-1234"), "id-1234");
    data.setTaskid("task1234");
    assertEquals(provider.getInstanceId(data, doc, "id-1234"), "task1234");
}
Also used : Struct(com.yahoo.rdl.Struct) Test(org.testng.annotations.Test)

Example 13 with Struct

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

the class ZMSFileChangeLogStoreCommon method setLastModificationTimestamp.

public void setLastModificationTimestamp(String newLastModTime) {
    lastModTime = newLastModTime;
    if (lastModTime == null) {
        delete(LAST_MOD_FNAME);
    } else {
        // update the last modification timestamp
        Struct lastModStruct = new Struct();
        lastModStruct.put(ATTR_LAST_MOD_TIME, lastModTime);
        put(LAST_MOD_FNAME, jsonValueAsBytes(lastModStruct, Struct.class));
    }
}
Also used : Struct(com.yahoo.rdl.Struct)

Example 14 with Struct

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

the class DBServiceTest method createEntityObject.

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

Example 15 with Struct

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

the class DBServiceTest method testExecutePutEntity.

@Test
public void testExecutePutEntity() {
    String domainName = "createentitydom1";
    String entityName = "entity1";
    TopLevelDomain dom1 = createTopLevelDomainObject(domainName, "Test Domain1", "testOrg", adminUser);
    zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom1);
    Entity entity1 = createEntityObject(domainName, entityName);
    zms.dbService.executePutEntity(mockDomRsrcCtx, domainName, entityName, entity1, auditRef, "putEntity");
    Entity entity2 = zms.getEntity(mockDomRsrcCtx, domainName, entityName);
    assertNotNull(entity2);
    assertEquals(entity2.getName(), ResourceUtils.entityResourceName(domainName, entityName));
    Struct value = entity2.getValue();
    assertEquals("Value1", value.getString("Key1"));
    zms.deleteTopLevelDomain(mockDomRsrcCtx, domainName, auditRef);
}
Also used : Struct(com.yahoo.rdl.Struct) Test(org.testng.annotations.Test)

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