use of io.cdap.cdap.api.security.store.SecureStoreMetadata in project cdap by caskdata.
the class FileSecureStoreServiceTest method testGet.
@Test
public void testGet() throws Exception {
populateStore();
SecureStoreMetadata metadata = new SecureStoreMetadata(KEY1, DESCRIPTION1, System.currentTimeMillis(), PROPERTIES_1);
SecureStoreData secureStoreData = new SecureStoreData(metadata, VALUE1.getBytes(Charsets.UTF_8));
Assert.assertArrayEquals(secureStoreData.get(), secureStore.get(NAMESPACE1, KEY1).get());
Assert.assertEquals(metadata.getDescription(), secureStore.get(NAMESPACE1, KEY1).getMetadata().getDescription());
Assert.assertEquals(metadata.getName(), secureStore.get(NAMESPACE1, KEY1).getMetadata().getName());
}
use of io.cdap.cdap.api.security.store.SecureStoreMetadata in project cdap by caskdata.
the class FileSecureStoreServiceTest method testGetMetadata.
@Test
public void testGetMetadata() throws Exception {
populateStore();
SecureStoreMetadata metadata = new SecureStoreMetadata(KEY1, DESCRIPTION1, System.currentTimeMillis(), PROPERTIES_1);
Assert.assertEquals(metadata.getDescription(), secureStore.get(NAMESPACE1, KEY1).getMetadata().getDescription());
Assert.assertEquals(metadata.getName(), secureStore.get(NAMESPACE1, KEY1).getMetadata().getName());
SecureStoreMetadata metadata2 = new SecureStoreMetadata(KEY2, DESCRIPTION2, System.currentTimeMillis(), PROPERTIES_2);
Assert.assertEquals(metadata2.getDescription(), secureStore.get(NAMESPACE1, KEY2).getMetadata().getDescription());
Assert.assertEquals(metadata2.getName(), secureStore.get(NAMESPACE1, KEY2).getMetadata().getName());
}
use of io.cdap.cdap.api.security.store.SecureStoreMetadata in project cdap by caskdata.
the class FileSecureStoreServiceTest method testDelete.
@Test(expected = NotFoundException.class)
public void testDelete() throws Exception {
populateStore();
SecureStoreMetadata metadata = new SecureStoreMetadata(KEY1, DESCRIPTION1, System.currentTimeMillis(), PROPERTIES_1);
SecureStoreData secureStoreData = new SecureStoreData(metadata, VALUE1.getBytes(Charsets.UTF_8));
Assert.assertArrayEquals(secureStoreData.get(), secureStore.get(NAMESPACE1, KEY1).get());
secureStoreManager.delete(NAMESPACE1, KEY1);
try {
secureStore.get(NAMESPACE1, KEY1);
} catch (IOException ioe) {
Assert.assertTrue(ioe.getMessage().contains("not found in the secure store"));
throw ioe;
}
}
use of io.cdap.cdap.api.security.store.SecureStoreMetadata in project cdap by caskdata.
the class SecretManagerSecureStoreService method get.
@Override
public SecureStoreData get(String namespace, String name) throws Exception {
validate(namespace);
try {
Secret secret = secretManager.get(namespace, name);
SecretMetadata metadata = secret.getMetadata();
return new SecureStoreData(new SecureStoreMetadata(metadata.getName(), metadata.getDescription(), metadata.getCreationTimeMs(), metadata.getProperties()), secret.getData());
} catch (SecretNotFoundException e) {
throw new SecureKeyNotFoundException(new SecureKeyId(namespace, name), e);
}
}
use of io.cdap.cdap.api.security.store.SecureStoreMetadata in project cdap by caskdata.
the class SecretManagerSecureStoreService method list.
@Override
public List<SecureStoreMetadata> list(String namespace) throws Exception {
validate(namespace);
List<SecureStoreMetadata> metadataList = new ArrayList<>();
for (SecretMetadata metadata : secretManager.list(namespace)) {
metadataList.add(new SecureStoreMetadata(metadata.getName(), metadata.getDescription(), metadata.getCreationTimeMs(), metadata.getProperties()));
}
return metadataList;
}
Aggregations