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