Search in sources :

Example 1 with DynamoDbConnectionBuilder

use of com.formkiq.stacks.dynamodb.DynamoDbConnectionBuilder in project formkiq-core by formkiq.

the class AbstractApiTest method setupConfigService.

private static void setupConfigService(final String awsprofile) {
    String documentsTable = ssmService.getParameterValue("/formkiq/" + appenvironment + "/dynamodb/DocumentsTableName");
    DynamoDbConnectionBuilder dbConnection = new DynamoDbConnectionBuilder().setCredentials(awsprofile).setRegion(awsregion);
    configService = new ConfigServiceImpl(dbConnection, documentsTable);
}
Also used : ConfigServiceImpl(com.formkiq.stacks.dynamodb.ConfigServiceImpl) DynamoDbConnectionBuilder(com.formkiq.stacks.dynamodb.DynamoDbConnectionBuilder)

Example 2 with DynamoDbConnectionBuilder

use of com.formkiq.stacks.dynamodb.DynamoDbConnectionBuilder in project formkiq-core by formkiq.

the class WebsocketTest method beforeClass.

/**
 * beforeclass.
 *
 * @throws IOException IOException
 * @throws URISyntaxException URISyntaxException
 */
@BeforeClass
public static void beforeClass() throws IOException, URISyntaxException {
    Region awsregion = Region.of(System.getProperty("testregion"));
    String awsprofile = System.getProperty("testprofile");
    String app = System.getProperty("testappenvironment");
    SqsConnectionBuilder sqsConnection = new SqsConnectionBuilder().setCredentials(awsprofile).setRegion(awsregion);
    sqsService = new SqsService(sqsConnection);
    SsmConnectionBuilder ssmBuilder = new SsmConnectionBuilder().setCredentials(awsprofile).setRegion(awsregion);
    SsmService ssmService = new SsmServiceImpl(ssmBuilder);
    websocketSqsUrl = ssmService.getParameterValue("/formkiq/" + app + "/sqs/WebsocketUrl");
    websocketUrl = ssmService.getParameterValue("/formkiq/" + app + "/api/WebsocketUrl");
    String cognitoUserPoolId = ssmService.getParameterValue("/formkiq/" + app + "/cognito/UserPoolId");
    String cognitoClientId = ssmService.getParameterValue("/formkiq/" + app + "/cognito/UserPoolClientId");
    String cognitoIdentitypool = ssmService.getParameterValue("/formkiq/" + app + "/cognito/IdentityPoolId");
    CognitoConnectionBuilder adminBuilder = new CognitoConnectionBuilder(cognitoClientId, cognitoUserPoolId, cognitoIdentitypool).setCredentials(awsprofile).setRegion(awsregion);
    adminCognitoService = new CognitoService(adminBuilder);
    addAndLoginCognito(USER_EMAIL, GROUP);
    token = adminCognitoService.login(USER_EMAIL, USER_PASSWORD);
    String rootHttpUrl = ssmService.getParameterValue("/formkiq/" + app + "/api/DocumentsHttpUrl");
    FormKiqClientConnection connection = new FormKiqClientConnection(rootHttpUrl).cognitoIdToken(token.idToken()).header("Origin", Arrays.asList("http://localhost")).header("Access-Control-Request-Method", Arrays.asList("GET"));
    httpClient = new FormKiqClientV1(connection);
    webconnectionsTable = ssmService.getParameterValue("/formkiq/" + app + "/dynamodb/WebConnectionsTableName");
    dbConnection = new DynamoDbConnectionBuilder().setCredentials(awsprofile).setRegion(awsregion);
}
Also used : SsmService(com.formkiq.aws.ssm.SsmService) SsmServiceImpl(com.formkiq.aws.ssm.SsmServiceImpl) CognitoConnectionBuilder(com.formkiq.aws.cognito.CognitoConnectionBuilder) SqsConnectionBuilder(com.formkiq.aws.sqs.SqsConnectionBuilder) SsmConnectionBuilder(com.formkiq.aws.ssm.SsmConnectionBuilder) SqsService(com.formkiq.aws.sqs.SqsService) FormKiqClientConnection(com.formkiq.stacks.client.FormKiqClientConnection) Region(software.amazon.awssdk.regions.Region) CognitoService(com.formkiq.aws.cognito.CognitoService) DynamoDbConnectionBuilder(com.formkiq.stacks.dynamodb.DynamoDbConnectionBuilder) FormKiqClientV1(com.formkiq.stacks.client.FormKiqClientV1) BeforeClass(org.junit.BeforeClass)

Example 3 with DynamoDbConnectionBuilder

use of com.formkiq.stacks.dynamodb.DynamoDbConnectionBuilder in project formkiq-core by formkiq.

the class DocumentsRestrictionsMaxContentLengthTest method before.

/**
 * Before Tests.
 * @throws URISyntaxException URISyntaxException
 * @throws IOException IOException
 */
@BeforeEach
public void before() throws URISyntaxException, IOException {
    DynamoDbConnectionBuilder adb = DynamoDbTestServices.getDynamoDbConnection(null);
    DynamoDbHelper dbhelper = new DynamoDbHelper(adb);
    this.awsservice = new AwsServiceCache().dbConnection(adb, dbhelper.getDocumentTable(), "").appEnvironment("unittest");
}
Also used : DynamoDbHelper(com.formkiq.stacks.dynamodb.DynamoDbHelper) AwsServiceCache(com.formkiq.lambda.apigateway.AwsServiceCache) DynamoDbConnectionBuilder(com.formkiq.stacks.dynamodb.DynamoDbConnectionBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with DynamoDbConnectionBuilder

use of com.formkiq.stacks.dynamodb.DynamoDbConnectionBuilder in project formkiq-core by formkiq.

the class AbstractAwsTest method beforeClass.

/**
 * beforeclass.
 *
 * @throws IOException IOException
 */
@BeforeClass
public static void beforeClass() throws IOException {
    awsregion = Region.of(System.getProperty("testregion"));
    String awsprofile = System.getProperty("testprofile");
    appenvironment = System.getProperty("testappenvironment");
    final SqsConnectionBuilder sqsConnection = new SqsConnectionBuilder().setCredentials(awsprofile).setRegion(awsregion);
    final SsmConnectionBuilder ssmBuilder = new SsmConnectionBuilder().setCredentials(awsprofile).setRegion(awsregion);
    final S3ConnectionBuilder s3Builder = new S3ConnectionBuilder().setCredentials(awsprofile).setRegion(awsregion);
    final SnsConnectionBuilder snsBuilder = new SnsConnectionBuilder().setCredentials(awsprofile).setRegion(awsregion);
    sqsService = new SqsService(sqsConnection);
    s3Service = new S3Service(s3Builder);
    ssmService = new SsmServiceImpl(ssmBuilder);
    snsService = new SnsService(snsBuilder);
    sesbucketname = ssmService.getParameterValue("/formkiq/" + appenvironment + "/s3/DocumentsSesS3Bucket");
    documentsbucketname = ssmService.getParameterValue("/formkiq/" + appenvironment + "/s3/DocumentsS3Bucket");
    stagingdocumentsbucketname = ssmService.getParameterValue("/formkiq/" + appenvironment + "/s3/DocumentsStageS3Bucket");
    snsDocumentEventArn = ssmService.getParameterValue("/formkiq/" + appenvironment + "/sns/DocumentEventArn");
    String documentsTable = ssmService.getParameterValue("/formkiq/" + appenvironment + "/dynamodb/DocumentsTableName");
    DynamoDbConnectionBuilder dbConnection = new DynamoDbConnectionBuilder().setCredentials(awsprofile).setRegion(awsregion);
    documentService = new DocumentServiceImpl(dbConnection, documentsTable);
}
Also used : DocumentServiceImpl(com.formkiq.stacks.dynamodb.DocumentServiceImpl) SsmServiceImpl(com.formkiq.aws.ssm.SsmServiceImpl) SqsConnectionBuilder(com.formkiq.aws.sqs.SqsConnectionBuilder) SsmConnectionBuilder(com.formkiq.aws.ssm.SsmConnectionBuilder) SnsService(com.formkiq.aws.sns.SnsService) S3ConnectionBuilder(com.formkiq.aws.s3.S3ConnectionBuilder) SqsService(com.formkiq.aws.sqs.SqsService) SnsConnectionBuilder(com.formkiq.aws.sns.SnsConnectionBuilder) S3Service(com.formkiq.aws.s3.S3Service) DynamoDbConnectionBuilder(com.formkiq.stacks.dynamodb.DynamoDbConnectionBuilder) BeforeClass(org.junit.BeforeClass)

Example 5 with DynamoDbConnectionBuilder

use of com.formkiq.stacks.dynamodb.DynamoDbConnectionBuilder in project formkiq-core by formkiq.

the class DynamoDbTestServices method getDynamoDbConnection.

/**
 * Get Singleton Instance of {@link DynamoDbConnectionBuilder}.
 * @param dynamoDb {@link GenericContainer}
 * @return {@link DynamoDbConnectionBuilder}
 * @throws URISyntaxException URISyntaxException
 */
public static DynamoDbConnectionBuilder getDynamoDbConnection(final GenericContainer<?> dynamoDb) throws URISyntaxException {
    if (dbConnection == null) {
        AwsCredentialsProvider cred = StaticCredentialsProvider.create(AwsSessionCredentials.create("ACCESSKEY", "SECRETKEY", "TOKENKEY"));
        dbConnection = new DynamoDbConnectionBuilder().setRegion(AWS_REGION).setCredentials(cred).setEndpointOverride("http://localhost:" + dynamoDb.getFirstMappedPort());
    }
    return dbConnection;
}
Also used : AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) DynamoDbConnectionBuilder(com.formkiq.stacks.dynamodb.DynamoDbConnectionBuilder)

Aggregations

DynamoDbConnectionBuilder (com.formkiq.stacks.dynamodb.DynamoDbConnectionBuilder)7 SsmConnectionBuilder (com.formkiq.aws.ssm.SsmConnectionBuilder)3 SsmServiceImpl (com.formkiq.aws.ssm.SsmServiceImpl)3 BeforeClass (org.junit.BeforeClass)3 SqsConnectionBuilder (com.formkiq.aws.sqs.SqsConnectionBuilder)2 SqsService (com.formkiq.aws.sqs.SqsService)2 AwsCredentialsProvider (software.amazon.awssdk.auth.credentials.AwsCredentialsProvider)2 CognitoConnectionBuilder (com.formkiq.aws.cognito.CognitoConnectionBuilder)1 CognitoService (com.formkiq.aws.cognito.CognitoService)1 S3ConnectionBuilder (com.formkiq.aws.s3.S3ConnectionBuilder)1 S3Service (com.formkiq.aws.s3.S3Service)1 SnsConnectionBuilder (com.formkiq.aws.sns.SnsConnectionBuilder)1 SnsService (com.formkiq.aws.sns.SnsService)1 SsmService (com.formkiq.aws.ssm.SsmService)1 AwsServiceCache (com.formkiq.lambda.apigateway.AwsServiceCache)1 FormKiqClientConnection (com.formkiq.stacks.client.FormKiqClientConnection)1 FormKiqClientV1 (com.formkiq.stacks.client.FormKiqClientV1)1 ConfigServiceImpl (com.formkiq.stacks.dynamodb.ConfigServiceImpl)1 DocumentServiceImpl (com.formkiq.stacks.dynamodb.DocumentServiceImpl)1 DynamoDbHelper (com.formkiq.stacks.dynamodb.DynamoDbHelper)1