def integration_03b_ensure_stack_absent(self): actor = cloudformation.Stack( options={ 'region': self.region, 'state': 'absent', 'name': self.bucket_name, 'template': 'examples/test/aws.cloudformation/cf.integration.json', 'parameters': { 'BucketName': '%s-updated' % self.bucket_name, 'BucketPassword': UUID, 'Metadata': UUID }}) done = yield actor.execute() self.assertEquals(done, None)
def integration_04b_update_bucket_name_second_time_should_work(self): actor = cloudformation.Stack( options={ 'region': self.region, 'state': 'present', 'name': self.bucket_name, 'template': 'examples/test/aws.cloudformation/cf.integration.json', 'parameters': { 'BucketName': '%s-updated' % self.bucket_name, 'BucketPassword': UUID, 'Metadata': UUID } }) done = yield actor.execute() self.assertEqual(done, None)
def test_diff_params_safely(self): self.actor = cloudformation.Stack( options={ 'name': 'unit-test-cf', 'state': 'present', 'region': 'us-west-2', 'template': 'examples/test/aws.cloudformation/cf.integration.json', 'parameters': { 'BucketName': 'name', 'BucketPassword': '******', 'Metadata': '1.0' } }) # Pretend that the parameters are the same (BucketName and Metadata), # and the BucketPassword came back with stars. We should still return # False to indicate that the parameters are the same. remote = [{ 'ParameterKey': 'BucketName', 'ParameterValue': 'name' }, { 'ParameterKey': 'BucketPassword', 'ParameterValue': '***' }, { 'ParameterKey': 'Metadata', 'ParameterValue': '1.0' }] ret = self.actor._diff_params_safely(remote, self.actor._parameters) self.assertEquals(False, ret) # Now pretend that the Metadata is different ... Should return True # indicating that the lists are different. remote = [{ 'ParameterKey': 'BucketName', 'ParameterValue': 'name' }, { 'ParameterKey': 'BucketPassword', 'ParameterValue': '***' }, { 'ParameterKey': 'Metadata', 'ParameterValue': '2.0' }] ret = self.actor._diff_params_safely(remote, self.actor._parameters) self.assertEquals(True, ret)
def integration_03_update_by_overriding_default(self): actor = cloudformation.Stack( options={ 'region': self.region, 'state': 'present', 'name': self.bucket_name, 'template': 'examples/test/aws.cloudformation/cf.integration.json', 'parameters': { 'BucketName': self.bucket_name, 'BucketPassword': UUID, 'DefaultParam': 'OverriddenValue', 'Metadata': UUID } }) done = yield actor.execute() self.assertEquals(done, None)
def setUp(self): super(TestStack, self).setUp() settings.AWS_ACCESS_KEY_ID = 'unit-test' settings.AWS_SECRET_ACCESS_KEY = 'unit-test' settings.RETRYING_SETTINGS = {'stop_max_attempt_number': 1} reload(cloudformation) self.actor = cloudformation.Stack( options={ 'name': 'unit-test-cf', 'state': 'present', 'region': 'us-west-2', 'template': 'examples/test/aws.cloudformation/cf.unittest.json', 'parameters': { 'key1': 'value1' } }) self.actor.cf3_conn = mock.MagicMock(name='cf3_conn')
def integration_01c_changing_password_should_be_a_noop(self): # This should pretty much do nothing.. if it did trigger a ChangeSet, # we would actually fail because we're issuing a ChangeSet where no # resources are actually modified. Thus, if this succeeds, we know # that no stack change was made. actor = cloudformation.Stack( options={ 'region': self.region, 'state': 'present', 'name': self.bucket_name, 'template': 'examples/test/aws.cloudformation/cf.integration.json', 'parameters': { 'BucketName': self.bucket_name, 'BucketPassword': '******', 'Metadata': UUID }}) done = yield actor.execute() self.assertEquals(done, None)
def setUp(self): super(TestStack, self).setUp() settings.AWS_ACCESS_KEY_ID = 'unit-test' settings.AWS_SECRET_ACCESS_KEY = 'unit-test' settings.RETRYING_SETTINGS = {'stop_max_attempt_number': 1} reload(cloudformation) # Need to recreate the api call queues between tests # because nose creates a new ioloop per test run. base.NAMED_API_CALL_QUEUES = {} self.actor = cloudformation.Stack( options={ 'name': 'unit-test-cf', 'state': 'present', 'region': 'us-west-2', 'template': 'examples/test/aws.cloudformation/cf.unittest.json', 'parameters': { 'key1': 'value1' } }) self.actor.cf3_conn = mock.MagicMock(name='cf3_conn')
def test_diff_params_safely(self): self.actor = cloudformation.Stack( options={ 'name': 'unit-test-cf', 'state': 'present', 'region': 'us-west-2', 'template': 'examples/test/aws.cloudformation/cf.integration.json', 'parameters': { 'BucketName': 'name', 'BucketPassword': '******', 'Metadata': '1.0' } }) # Pretend that the parameters are the same # (BucketName, DefaultParam, and Metadata), and the BucketPassword # came back with stars. # We should still return False to indicate that the parameters # are the same. remote = [ {'ParameterKey': 'BucketName', 'ParameterValue': 'name'}, {'ParameterKey': 'BucketPassword', 'ParameterValue': '***'}, {'ParameterKey': 'DefaultParam', 'ParameterValue': 'DefaultValue'}, {'ParameterKey': 'Metadata', 'ParameterValue': '1.0'} ] ret = self.actor._diff_params_safely(remote, self.actor._parameters) self.assertEquals(False, ret) # Now pretend that the Metadata is different ... Should return True # indicating that the lists are different. remote = [ {'ParameterKey': 'BucketName', 'ParameterValue': 'name'}, {'ParameterKey': 'BucketPassword', 'ParameterValue': '***'}, {'ParameterKey': 'Metadata', 'ParameterValue': '2.0', 'ResolvedValue': 'Resolved'} ] ret = self.actor._diff_params_safely(remote, self.actor._parameters) self.assertEquals(True, ret) # Now try updating the parameter with a default and # pretend the remote had a different value. Should return True. self.actor._options['parameters']['DefaultParam'] = 'NewValue' self.actor._parameters = self.actor._create_parameters( self.actor._options['parameters']) remote = [ {'ParameterKey': 'BucketName', 'ParameterValue': 'name'}, {'ParameterKey': 'BucketPassword', 'ParameterValue': '***'}, {'ParameterKey': 'Metadata', 'ParameterValue': '2.0'}, {'ParameterKey': 'DefaultParam', 'ParameterValue': 'EntirelyDifferentValue'}, ] ret = self.actor._diff_params_safely(remote, self.actor._parameters) self.assertEquals(True, ret) # Now try updating the parameter with a default and # pretend the remote had the default value. Should still return True. self.actor._options['parameters']['DefaultParam'] = 'AnotherNewValue' self.actor._parameters = self.actor._create_parameters( self.actor._options['parameters']) remote = [ {'ParameterKey': 'BucketName', 'ParameterValue': 'name'}, {'ParameterKey': 'BucketPassword', 'ParameterValue': '***'}, {'ParameterKey': 'Metadata', 'ParameterValue': '2.0'}, {'ParameterKey': 'DefaultParam', 'ParameterValue': 'DefaultValue'}, ] ret = self.actor._diff_params_safely(remote, self.actor._parameters) self.assertEquals(True, ret)