Search in sources :

Example 11 with AmazonDynamoDBException

use of com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException in project athenz by yahoo.

the class DynamoDBCertRecordStoreConnectionTest method testDeleteX509RecordException.

@Test
public void testDeleteX509RecordException() {
    Mockito.doThrow(new AmazonDynamoDBException("invalid operation")).when(table).deleteItem(any(DeleteItemSpec.class));
    DynamoDBCertRecordStoreConnection dbConn = getDBConnection();
    boolean requestSuccess = dbConn.deleteX509CertRecord("athenz.provider", "12345", "cn");
    assertFalse(requestSuccess);
    dbConn.close();
}
Also used : DeleteItemSpec(com.amazonaws.services.dynamodbv2.document.spec.DeleteItemSpec) AmazonDynamoDBException(com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException) Test(org.testng.annotations.Test)

Example 12 with AmazonDynamoDBException

use of com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException in project athenz by yahoo.

the class DynamoDBCertRecordStoreConnectionTest method testInsertX509RecordException.

@Test
public void testInsertX509RecordException() {
    Date now = new Date();
    X509CertRecord certRecord = getRecordNonNullableColumns(now);
    Mockito.doThrow(new AmazonDynamoDBException("invalid operation")).when(table).putItem(any(Item.class));
    DynamoDBCertRecordStoreConnection dbConn = getDBConnection();
    boolean requestSuccess = dbConn.insertX509CertRecord(certRecord);
    assertFalse(requestSuccess);
    dbConn.close();
}
Also used : AmazonDynamoDBException(com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException) X509CertRecord(com.yahoo.athenz.common.server.cert.X509CertRecord) Test(org.testng.annotations.Test)

Example 13 with AmazonDynamoDBException

use of com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException in project athenz by yahoo.

the class DynamoDBCertRecordStoreConnectionTest method testGetX509CertRecordNotFoundException.

@Test
public void testGetX509CertRecordNotFoundException() {
    Mockito.doThrow(new AmazonDynamoDBException("item not found")).when(table).getItem("primaryKey", "athenz.provider:cn:1234");
    DynamoDBCertRecordStoreConnection dbConn = getDBConnection();
    X509CertRecord certRecord = dbConn.getX509CertRecord("athenz.provider", "1234", "cn");
    assertNull(certRecord);
    dbConn.close();
}
Also used : AmazonDynamoDBException(com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException) X509CertRecord(com.yahoo.athenz.common.server.cert.X509CertRecord) Test(org.testng.annotations.Test)

Example 14 with AmazonDynamoDBException

use of com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException in project athenz by yahoo.

the class DynamoDBCertRecordStoreConnectionTest method testUpdateX509RecordException.

@Test
public void testUpdateX509RecordException() {
    Date now = new Date();
    X509CertRecord certRecord = getRecordNonNullableColumns(now);
    Mockito.doThrow(new AmazonDynamoDBException("invalid operation")).when(table).updateItem(any(UpdateItemSpec.class));
    DynamoDBCertRecordStoreConnection dbConn = getDBConnection();
    boolean requestSuccess = dbConn.updateX509CertRecord(certRecord);
    assertFalse(requestSuccess);
    dbConn.close();
}
Also used : AmazonDynamoDBException(com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException) UpdateItemSpec(com.amazonaws.services.dynamodbv2.document.spec.UpdateItemSpec) X509CertRecord(com.yahoo.athenz.common.server.cert.X509CertRecord) Test(org.testng.annotations.Test)

Example 15 with AmazonDynamoDBException

use of com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException in project athenz by yahoo.

the class DynamoDBSSHRecordStoreConnectionTest method testUpdateSSHRecordException.

@Test
public void testUpdateSSHRecordException() {
    SSHCertRecord certRecord = new SSHCertRecord();
    Mockito.doThrow(new AmazonDynamoDBException("invalid operation")).when(table).updateItem(ArgumentMatchers.any(UpdateItemSpec.class));
    DynamoDBSSHRecordStoreConnection dbConn = new DynamoDBSSHRecordStoreConnection(dynamoDB, tableName);
    boolean requestSuccess = dbConn.updateSSHCertRecord(certRecord);
    assertFalse(requestSuccess);
    dbConn.close();
}
Also used : AmazonDynamoDBException(com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException) UpdateItemSpec(com.amazonaws.services.dynamodbv2.document.spec.UpdateItemSpec) SSHCertRecord(com.yahoo.athenz.common.server.ssh.SSHCertRecord) Test(org.testng.annotations.Test)

Aggregations

AmazonDynamoDBException (com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException)16 Test (org.testng.annotations.Test)13 UpdateItemSpec (com.amazonaws.services.dynamodbv2.document.spec.UpdateItemSpec)4 X509CertRecord (com.yahoo.athenz.common.server.cert.X509CertRecord)4 WorkloadRecord (com.yahoo.athenz.common.server.workload.WorkloadRecord)4 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)3 QuerySpec (com.amazonaws.services.dynamodbv2.document.spec.QuerySpec)3 AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)3 SSHCertRecord (com.yahoo.athenz.common.server.ssh.SSHCertRecord)3 DeleteItemSpec (com.amazonaws.services.dynamodbv2.document.spec.DeleteItemSpec)2 DynamoDBMapper (com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper)1 QueryRequest (com.amazonaws.services.dynamodbv2.model.QueryRequest)1 QueryResult (com.amazonaws.services.dynamodbv2.model.QueryResult)1 ScanRequest (com.amazonaws.services.dynamodbv2.model.ScanRequest)1 ScanResult (com.amazonaws.services.dynamodbv2.model.ScanResult)1 HashMap (java.util.HashMap)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1