Search in sources :

Example 1 with InputConfiguration

use of org.sagebionetworks.stack.config.InputConfiguration in project Synapse-Stack-Builder by Sage-Bionetworks.

the class InputConfigurationTest method testIsProdcution.

@Test
public void testIsProdcution() throws IOException {
    // This is a production stack
    inputProperties.put(STACK, "prod");
    InputConfiguration config = new InputConfiguration(inputProperties);
    assertTrue(config.isProductionStack());
    // Also a prod stack
    inputProperties.put(STACK, "PROD");
    config = new InputConfiguration(inputProperties);
    assertTrue(config.isProductionStack());
    // A dev stack in NOT a production stack.
    inputProperties.put(STACK, "dev");
    config = new InputConfiguration(inputProperties);
    assertFalse(config.isProductionStack());
}
Also used : InputConfiguration(org.sagebionetworks.stack.config.InputConfiguration) Test(org.junit.Test)

Example 2 with InputConfiguration

use of org.sagebionetworks.stack.config.InputConfiguration in project Synapse-Stack-Builder by Sage-Bionetworks.

the class InputConfigurationTest method testAddPropertiesWithPlaintext.

@Test
public void testAddPropertiesWithPlaintext() throws IOException {
    InputConfiguration config = new InputConfiguration(inputProperties);
    // These are properties that we want encrypted
    Properties props = new Properties();
    String plainTextKey = "key.one." + PLAIN_TEXT_SUFFIX;
    String encryptedKey = "key.one." + ENCRYPTED_SUFFIX;
    String plainText = "Please encrypte me!";
    props.put(plainTextKey, plainText);
    props.put("key.two", "Do not encrypt me!");
    // Add the properties
    config.addPropertiesWithPlaintext(props);
    // Make sure the original properties are there
    assertEquals(plainText, config.validateAndGetProperty(plainTextKey));
    assertEquals("Do not encrypt me!", config.validateAndGetProperty("key.two"));
    // Now check the expected encrypted key
    String expectedCipherText = EncryptionUtils.encryptString(config.getEncryptionKey(), plainText);
    assertEquals(expectedCipherText, config.validateAndGetProperty(encryptedKey));
}
Also used : Properties(java.util.Properties) InputConfiguration(org.sagebionetworks.stack.config.InputConfiguration) Test(org.junit.Test)

Example 3 with InputConfiguration

use of org.sagebionetworks.stack.config.InputConfiguration in project Synapse-Stack-Builder by Sage-Bionetworks.

the class InputConfigurationTest method testStackPasswords.

@Test
public void testStackPasswords() throws IOException {
    // Load from the properties
    InputConfiguration config = new InputConfiguration(inputProperties);
    Properties passwords = new Properties();
    String plainTextPassword = "password";
    String plainTextPassword2 = "password2";
    String expectedCipherText = EncryptionUtils.encryptString(config.getEncryptionKey(), plainTextPassword);
    String expectedCipherText2 = EncryptionUtils.encryptString(config.getEncryptionKey(), plainTextPassword2);
    passwords.put(KEY_DEFAULT_ID_GEN_PASSWORD_PLAIN_TEXT, plainTextPassword);
    passwords.put(Constants.KEY_DEFAULT_STACK_INSTANCES_DB_PASSWORD_PLAIN_TEXT, plainTextPassword2);
    config.addPropertiesWithPlaintext(passwords);
    // Make sure we can get both the plain text version and the encrypted versions
    assertEquals(plainTextPassword, config.getIdGeneratorDatabaseMasterPasswordPlaintext());
    assertEquals(expectedCipherText, config.validateAndGetProperty(KEY_DEFAULT_ID_GEN_PASSWORD_ENCRYPTED));
    assertEquals(plainTextPassword2, config.getStackInstanceDatabaseMasterPasswordPlaintext());
    assertEquals(expectedCipherText2, config.validateAndGetProperty(KEY_DEFAULT_STACK_INSTANCES_DB_PASSWORD_ENCRYPTED));
}
Also used : Properties(java.util.Properties) InputConfiguration(org.sagebionetworks.stack.config.InputConfiguration) Test(org.junit.Test)

Example 4 with InputConfiguration

use of org.sagebionetworks.stack.config.InputConfiguration in project Synapse-Stack-Builder by Sage-Bionetworks.

the class InputConfigurationTest method testConfig.

@Test
public void testConfig() throws IOException {
    // Load from the properties
    InputConfiguration config = new InputConfiguration(inputProperties);
    AWSCredentials creds = config.getAWSCredentials();
    assertNotNull(creds);
    assertEquals(id, creds.getAWSAccessKeyId());
    assertEquals(password, creds.getAWSSecretKey());
    assertEquals(encryptionKey, config.getEncryptionKey());
    assertEquals(stack, config.getStack());
    assertEquals(instance, config.getStackInstance());
    assertEquals(portalBeanstalkNumber, config.getPortalBeanstalkNumber());
    assertEquals(numberTableInstances, config.getNumberTableInstances());
}
Also used : InputConfiguration(org.sagebionetworks.stack.config.InputConfiguration) AWSCredentials(com.amazonaws.auth.AWSCredentials) Test(org.junit.Test)

Example 5 with InputConfiguration

use of org.sagebionetworks.stack.config.InputConfiguration in project Synapse-Stack-Builder by Sage-Bionetworks.

the class InputConfigurationTest method testStackInstanceNames.

@Test
public void testStackInstanceNames() throws IOException {
    // Load from the properties
    InputConfiguration config = new InputConfiguration(inputProperties);
    assertEquals(stack + "-default.sagebase.org", config.getDefaultS3BucketName());
    assertEquals(stack + "-default.properties", config.getDefaultPropertiesFileName());
    assertEquals("elastic-beanstalk-" + stack + "-" + instance, config.getElasticSecurityGroupName());
    assertEquals("All elastic beanstalk instances of stack:'" + stack + "' instance:'" + instance + "' belong to this EC2 security group", config.getElasticSecurityGroupDescription());
    assertEquals("mysql5-6-" + stack + "-params", config.getDatabaseParameterGroupName());
    assertEquals("Custom MySQL 5.6 database parameters (including slow query log enabled) used by all database instances belonging to stack: " + stack, config.getDatabaseParameterGroupDescription());
    // Id gen database
    String expectedIdGenIdentifier = stack + "-id-generator-db";
    assertEquals(expectedIdGenIdentifier, config.getIdGeneratorDatabaseIdentifier());
    assertEquals(stack + "idgen", config.getIdGeneratorDatabaseSchemaName());
    assertEquals(stack + "idgenuser", config.getIdGeneratorDatabaseMasterUsername());
    // Stack database
    String expectedStackDBIdentifier = stack + "-" + instance + "-db";
    assertEquals(expectedStackDBIdentifier, config.getStackInstanceDatabaseIdentifier());
    assertEquals(stack + instance, config.getStackInstanceDatabaseSchema());
    assertEquals(stack + instance + "user", config.getStackInstanceDatabaseMasterUser());
    // Table instance databases
    int numTableInstances = Integer.parseInt(config.getNumberTableInstances());
    for (int instNum = 0; instNum < numTableInstances; instNum++) {
        String expectedStackTableInstanceIdentifier = stack + "-" + instance + "-table-" + instNum;
        assertEquals(expectedStackTableInstanceIdentifier, config.getStackTableDBInstanceDatabaseIdentifier(instNum));
        assertEquals(stack + instance, config.getStackInstanceTablesDBSchema());
        assertEquals(stack + instance + "user", config.getStackInstanceTablesDBMasterUser());
    }
    // The database security groups
    assertEquals(expectedIdGenIdentifier + "-security-group", config.getIdGeneratorDatabaseSecurityGroupName());
    assertEquals("The database security group used by the " + expectedIdGenIdentifier + ".", config.getIdGeneratorDatabaseSecurityGroupDescription());
    assertEquals(expectedStackDBIdentifier + "-security-group", config.getStackDatabaseSecurityGroupName());
    assertEquals("The database security group used by the " + expectedStackDBIdentifier + ".", config.getStackDatabaseSecurityGroupDescription());
    // the alert topic
    assertEquals(stack + "-" + instance + "-RDS-Alert", config.getRDSAlertTopicName());
    // environment instance alerts
    assertEquals("PORTAL-" + stack + "-" + instance + "-" + portalBeanstalkNumber + "-notification", config.getEnvironmentInstanceNotificationTopicName(StackEnvironmentType.PORTAL));
    assertEquals("REPO-" + stack + "-" + instance + "-" + plfmBeanstalkNumber + "-notification", config.getEnvironmentInstanceNotificationTopicName(StackEnvironmentType.REPO));
    // Main file S3 bucket
    assertEquals(stack + "data.sagebase.org", config.getMainFileS3BucketName());
    // ACM certs
    assertEquals("arn:aws:acm:us-east1:123456789012:certificate/12345678-1234-1234-1234-123456789012", config.getACMCertificateArn(StackEnvironmentType.PORTAL));
    assertEquals("arn:aws:acm:us-east1:123456789012:certificate/12345678-1234-1234-1234-223456789012", config.getACMCertificateArn(StackEnvironmentType.REPO));
    assertEquals("arn:aws:acm:us-east1:123456789012:certificate/12345678-1234-1234-1234-323456789012", config.getACMCertificateArn(StackEnvironmentType.WORKERS));
}
Also used : InputConfiguration(org.sagebionetworks.stack.config.InputConfiguration) Test(org.junit.Test)

Aggregations

InputConfiguration (org.sagebionetworks.stack.config.InputConfiguration)10 Properties (java.util.Properties)5 Test (org.junit.Test)5 Before (org.junit.Before)2 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)1 DescribeSecurityGroupsRequest (com.amazonaws.services.ec2.model.DescribeSecurityGroupsRequest)1 DescribeSecurityGroupsResult (com.amazonaws.services.ec2.model.DescribeSecurityGroupsResult)1 SecurityGroup (com.amazonaws.services.ec2.model.SecurityGroup)1 AmazonRDSClient (com.amazonaws.services.rds.AmazonRDSClient)1 DBParameterGroup (com.amazonaws.services.rds.model.DBParameterGroup)1 DescribeDBParameterGroupsRequest (com.amazonaws.services.rds.model.DescribeDBParameterGroupsRequest)1 DescribeDBParameterGroupsResult (com.amazonaws.services.rds.model.DescribeDBParameterGroupsResult)1 DescribeDBParametersRequest (com.amazonaws.services.rds.model.DescribeDBParametersRequest)1 DescribeDBParametersResult (com.amazonaws.services.rds.model.DescribeDBParametersResult)1 Parameter (com.amazonaws.services.rds.model.Parameter)1 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)1 GetObjectRequest (com.amazonaws.services.s3.model.GetObjectRequest)1 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)1 AmazonSNSClient (com.amazonaws.services.sns.AmazonSNSClient)1