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