aws-must-templates 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -29
  3. data/spec/aws-must-templates/AwsCommandLineInterfaceInstalled/AwsCommandLineInterfaceInstalled_spec.rb +10 -0
  4. data/spec/aws-must-templates/AwsMustTestRunnerProperties/AwsMustTestRunnerProperties_spec.rb +39 -0
  5. data/spec/aws-must-templates/CloudFormationHelperScriptsInstalled/CloudFormationHelperScriptsInstalled_spec.rb +21 -0
  6. data/spec/aws-must-templates/ParameterTest/ParameterTest_spec.rb +35 -0
  7. data/spec/aws-must-templates/S3NoAccess/S3NoAccess_spec.rb +72 -0
  8. data/spec/aws-must-templates/S3ReadAccessAllowed/S3ReadAccessAllowed_spec.rb +144 -0
  9. data/spec/aws-must-templates/Stack/Stack_spec.rb +49 -0
  10. data/spec/aws-must-templates/ValidOSVersion/ValidOSVersion_spec.rb +16 -0
  11. data/spec/lib/rspec_spec.rb +8 -0
  12. data/spec/lib/spec_helper.rb +1 -0
  13. data/spec/lib/test_suites_spec.rb +343 -0
  14. data/spec/mustache/commonCfnSignal_spec.rb +46 -0
  15. data/spec/mustache/commonCreationPolicy_spec.rb +58 -0
  16. data/spec/mustache/commonDependsOn_spec.rb +52 -0
  17. data/spec/mustache/commonInstanceType_spec.rb +75 -0
  18. data/spec/mustache/commonKeyValue_spec.rb +60 -0
  19. data/spec/mustache/commonStackRef_spec.rb +55 -0
  20. data/spec/mustache/commonValue_spec.rb +77 -0
  21. data/spec/mustache/initializeCFinit_spec.rb +38 -0
  22. data/spec/mustache/initializeCFtools_spec.rb +41 -0
  23. data/spec/mustache/initializeCfnInitHupFiles_spec.rb +105 -0
  24. data/spec/mustache/initializeInstallAwsCli_spec.rb +41 -0
  25. data/spec/mustache/initializeInstallChef_spec.rb +40 -0
  26. data/spec/mustache/initializeProvisionChefZero_spec.rb +40 -0
  27. data/spec/mustache/initializeStartCfnHup_spec.rb +37 -0
  28. data/spec/mustache/mappingSubnetConfig_spec.rb +45 -0
  29. data/spec/mustache/mapping_spec.rb +43 -0
  30. data/spec/mustache/mappings_spec.rb +42 -0
  31. data/spec/mustache/output_spec.rb +84 -0
  32. data/spec/mustache/parameter_spec.rb +46 -0
  33. data/spec/mustache/resourceInstanceInitialize_spec.rb +158 -0
  34. data/spec/mustache/resourceInstanceMetadata_spec.rb +85 -0
  35. data/spec/mustache/resourceInstanceProfile_spec.rb +55 -0
  36. data/spec/mustache/resourceInstance_spec.rb +51 -0
  37. data/spec/mustache/resourceInternetGateway_spec.rb +94 -0
  38. data/spec/mustache/resourcePolicy_spec.rb +107 -0
  39. data/spec/mustache/resourceProvisionChef_spec.rb +44 -0
  40. data/spec/mustache/resourceRole_spec.rb +66 -0
  41. data/spec/mustache/resourceS3Bucket_spec.rb +58 -0
  42. data/spec/mustache/resourceSecurityGroup_spec.rb +60 -0
  43. data/spec/mustache/resourceStack_spec.rb +60 -0
  44. data/spec/mustache/resourceSubnet_spec.rb +55 -0
  45. data/spec/mustache/resourceUser_spec.rb +67 -0
  46. data/spec/mustache/resourceVPC_spec.rb +57 -0
  47. data/spec/mustache/resourceWait_spec.rb +78 -0
  48. data/spec/mustache/resource_spec.rb +382 -0
  49. data/spec/mustache/resources_spec.rb +46 -0
  50. data/spec/mustache/root_spec.rb +165 -0
  51. data/spec/mustache/rspec_spec.rb +9 -0
  52. data/spec/mustache/spec_helper.rb +36 -0
  53. data/spec/mustache/tag_spec.rb +46 -0
  54. data/spec/support/lib/stack_output.rb +31 -0
  55. data/spec/support/lib/stack_parameter.rb +32 -0
  56. data/spec/support/lib/test_parameter.rb +64 -0
  57. data/spec/support/lib/valid_property.rb +63 -0
  58. data/spec/support/spec_helper.rb +134 -0
  59. data/spec/support/utils.rb +6 -0
  60. metadata +61 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf3a6e500d517d701c0215e0477fa9a8d595b979
4
- data.tar.gz: 1b2ac0944b78a61036e66e217c39eb47623a2a5e
3
+ metadata.gz: ecd754daf7d055170eebd8f71822e307d16bc46b
4
+ data.tar.gz: 26abbd64a494b9bd110404d5e6ee12665d55de48
5
5
  SHA512:
6
- metadata.gz: 0c17f5daae17aabf52b9cd254f9cd13e5d5189c7cd8125f1299fc1e4ab15a30e28693da298a50447fc2cac4dacd8ba86f3db744a448f80bcdf9487ffce2cf9dd
7
- data.tar.gz: 075de499bb571c08655a4a35df483ceaa4993bcae8c8ee75fe5a458a0420f8832df17a617c4b89a81ca3edf7656af809d5d72aff59361ce7c5898dad4bcf41eb
6
+ metadata.gz: 3b2d31cc6043c8980ae42827ffb0f5bfba188ab84fa74d294c01eaa1a3bde46dc213639d6942a204a786fc4f819b0353cb5ce88756100360274360a61b051ba8
7
+ data.tar.gz: 0ae4e92ade9306216892a408a71a4cf599c696cf6d934ac946bc401fef20d9d8fd48e8046356ec095f918d0fffc3391fe9e209273293cacae14ca31445293e61
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # aws-must-templates - cloudformation templates for aws-must - $Release:0.1.2$
1
+ # aws-must-templates - cloudformation templates for aws-must - $Release:0.1.3$
2
2
 
3
3
  Set of [extensible](#OVERRIDE)
4
4
  [templates](https://rawgit.com/jarjuk/aws-must-templates/master/generated-docs/aws-must-templates.html)
@@ -181,25 +181,23 @@ To use the **aws-must-templates** Test Runner
181
181
 
182
182
  ### Setup for Test Runner<a id="SETUP-TEST-RUNNER"/>
183
183
 
184
- Ensure that `Gemfile` includes
185
-
186
- gem 'rake'
187
- gem 'rspec'
188
- gem 'serverspec'
189
- gem 'aws-must-templates'
190
-
191
- Run `bundle install`, if new gems were added to the `Gemfile`.
192
-
193
184
  Add following lines to `Rakefile`
194
185
 
195
186
  spec = Gem::Specification.find_by_name 'aws-must-templates'
196
187
  load "#{spec.gem_dir}/lib/tasks/suite.rake"
197
188
 
189
+ create an empty `test-suites.yaml` -file
190
+
191
+ touch test-suites.yaml
192
+
198
193
  and run
199
194
 
200
195
  bundle exec rake -T suite
201
196
 
202
- to show new tasks for the Test Runner.
197
+ For an empty test-suites.yaml the result shows
198
+
199
+ rake suite:all[gen_opts] # Run all suites
200
+
203
201
 
204
202
  ### Prepare Test Context <a id="TEST-CONTEXT"/>
205
203
 
@@ -263,29 +261,30 @@ with the code shown:
263
261
  end
264
262
 
265
263
 
266
- See [test report](generated-docs/test-suites.md) created when running
267
- suites defined in [test-suites.yaml](test-suites.yaml), and
268
- [diagram](generated-docs/xref_suite_X_test.pdf) presenting Test Cases
269
- used in Test Suites.
264
+ For more information on Test Cases, see
265
+ [test report](generated-docs/test-suites.md) created, when running
266
+ [test-suites](test-suites.yaml) in **aws-must-templates** development,
267
+ and a [diagram](generated-docs/xref_suite_X_test.pdf) for an overview.
268
+
270
269
 
271
270
  ### Configure Test Suites <a id="TEST-SUITES"/>
272
271
 
273
- Test suites are configured in `test-suites.yaml`. Test runner search
274
- this file in current working directory.
272
+ Test Suites are configured in `test-suites.yaml`. Test Runner searches
273
+ this file in current working directory.
275
274
 
276
275
  The picture below present main elements used in `test-suites.yaml`.
277
276
 
278
277
  ![test-suites.yaml elements](./pics/test-suites.jpg)
279
278
 
280
- A Test Suite validates the correctness of a CloudFormation Stack. One
281
- Test Suite defines tests for multiple EC2 Instances. Each EC2 Instance
282
- must have a corresponding SSH Connection prepared in
279
+ A Test Suite validates correctness of a CloudFormation Stack. One Test
280
+ Suite defines tests for multiple EC2 Instances. Each EC2 Instance must
281
+ have a corresponding SSH Connection prepared in
283
282
  [ssh/config](#TEST-CONTEXT) -file. An EC2 Instance acts in many
284
283
  Roles. A Role maps to a [Test Case](#TEST_CASES), and and defines
285
284
  values for the Test Case Parameters. The parameter may be a constant,
286
285
  or a reference to Stack Parameter, or to Stack Output.
287
286
 
288
- An example Test Case for `mystack` is shown below
287
+ As an example, the Test Suite for `mystack` is
289
288
 
290
289
  - mystack:
291
290
  desc: Copy of suite1 EC2 instance with s3 access
@@ -297,22 +296,22 @@ An example Test Case for `mystack` is shown below
297
296
  - S3ReadAccessAllowed:
298
297
  Bucket: "@Outputs.Bucket"
299
298
 
300
- This configuration validates stack `mystack` by running two Test Cases
299
+ The Suite validates stack `mystack` by running two Test Cases
301
300
  `ValidOSVersion` and `S3ReadAccessAllowed` on EC2 instance
302
301
  `myInstance`.
303
302
 
304
- Test Case ValidOSVersion was presented [earlier](#TEST_CASES). It uses
305
- parameter `Codename` to validate operating system version. In this
306
- configuration, the parameter value is constant `utopic`. Effectively
307
- this validates that CloudFormation mapping used to
308
- [override](#OVERRIDE) the default implementation in
303
+ Test Case `ValidOSVersion` was presented [earlier](#TEST_CASES). It
304
+ uses parameter `Codename` to validate operating system version. In
305
+ this configuration, the parameter value is constant
306
+ `utopic`. Effectively this validates that CloudFormation mapping used
307
+ to [override](#OVERRIDE) the default implementation in
309
308
  **aws-must-templates** is successfully provisioned.
310
309
 
311
310
  Test Case `S3ReadAccessAllowed` is passed a parameter, which gets its
312
311
  value from stack output variable `Bucket`.
313
312
 
314
- See [test-suites.yaml](test-suites.yaml) in **aws-must-templatest**
315
- for more detailed explanation, and for more examples.
313
+ See [test-suites.yaml](test-suites.yaml) in **aws-must-templates** for
314
+ a more detailed explanation, and for more examples.
316
315
 
317
316
  ### Running test suites <a id="RUN-TESTS"/>
318
317
 
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe "AwsCommandLineInterfaceInstalled" do
4
+
5
+ describe command('type aws') do
6
+ its( :exit_status ) { should eq 0 }
7
+ end
8
+
9
+
10
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+
4
+
5
+ # ------------------------------------------------------------------
6
+ # Configuration
7
+ #
8
+
9
+ current_test = "AwsMustTestRunnerProperties"
10
+
11
+ # every suite should define these paramentes
12
+ system_properties = [
13
+ [:stack_id ],
14
+ [:suite_id ],
15
+ ["Outputs" ],
16
+ ["Parameters" ],
17
+ ]
18
+
19
+ # ------------------------------------------------------------------
20
+ #
21
+
22
+ describe current_test do
23
+
24
+ # ------------------------------------------------------------------
25
+ #
26
+ describe "System properties" do
27
+
28
+ system_properties.each do | keys |
29
+
30
+ describe valid_property( keys ) do
31
+ its( :value ) { should_not eq nil }
32
+ end
33
+
34
+ end
35
+ end
36
+
37
+
38
+ end
39
+
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe "CloudFormationHelperScriptsInstalled" do
4
+
5
+ describe command('type cfn-init') do
6
+ its( :exit_status ) { should eq 0 }
7
+ end
8
+
9
+ describe command('type cfn-signal') do
10
+ its( :exit_status ) { should eq 0 }
11
+ end
12
+
13
+ describe command('type cfn-get-metadata') do
14
+ its( :exit_status ) { should eq 0 }
15
+ end
16
+
17
+ describe command('type cfn-hup') do
18
+ its( :exit_status ) { should eq 0 }
19
+ end
20
+
21
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ current_test = "ParameterTest"
5
+
6
+ describe current_test do |ex|
7
+
8
+
9
+ # ------------------------------------------------------------------
10
+ # test parameters
11
+ parameter1 = test_parameter( current_test, "param1" )
12
+ parameter2 = test_parameter( current_test, "param2" )
13
+ parameter3 = test_parameter( current_test, "param3" )
14
+
15
+
16
+ # ------------------------------------------------------------------
17
+ # Test paramters defined
18
+
19
+ describe "Test parameter definition" do
20
+
21
+ describe parameter1 do
22
+ its( :definition_in_test_suite ) { should_not eq nil }
23
+ end
24
+
25
+ describe parameter2 do
26
+ its( :definition_in_test_suite ) { should_not eq nil }
27
+ end
28
+
29
+ describe parameter3 do
30
+ its( :definition_in_test_suite ) { should_not eq nil }
31
+ end
32
+
33
+ end # describe "Test parameters" do
34
+
35
+ end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ # ------------------------------------------------------------------
4
+ # config
5
+
6
+ current_test = "S3NoAccess"
7
+
8
+ # ------------------------------------------------------------------
9
+ # Tests
10
+
11
+ describe current_test do
12
+
13
+ # ------------------------------------------------------------------
14
+ # test parameters
15
+
16
+ bucket_name = test_parameter( current_test, "Bucket" )
17
+
18
+ # ------------------------------------------------------------------
19
+ # Context NO access granted
20
+
21
+ context "When Bucket exists" do
22
+
23
+ before(:all) do
24
+ cmd = "aws s3 ls s3://#{bucket_name.value}"
25
+ `#{cmd}`
26
+ raise "Error in '#{cmd}' " unless $? == 0
27
+ end
28
+
29
+ describe "#cannot list Bucket" do
30
+ describe command('aws s3 ls') do
31
+ its( :exit_status ) { should_not eq 0 }
32
+ end
33
+ end
34
+
35
+ test_file="ttest22.tmp"
36
+
37
+
38
+ context "When Object exists in Bucket" do
39
+
40
+ # File copy succeed --> bucket exists
41
+ before() do
42
+ cmd = "echo tst | aws s3 cp - s3://#{bucket_name.value}/#{test_file}"
43
+ `#{cmd}`
44
+ raise "Error in '#{cmd}' " unless $? == 0
45
+ end
46
+
47
+ after(:all) do
48
+ cmd = "aws s3 rm s3://#{bucket_name.value}/#{test_file}"
49
+ `#{cmd}`
50
+ raise "Error in '#{cmd}' " unless $? == 0
51
+ end
52
+
53
+ describe "#cannot list S3 bucket keys" do
54
+ describe command( "aws s3 ls s3://#{bucket_name.value} --region $(aws s3api get-bucket-location --bucket #{bucket_name.value} --output text)") do
55
+ its( :exit_status ) { should_not eq 0 }
56
+ end
57
+ end
58
+
59
+ describe "#cannot cp S3 bucket object" do
60
+ describe command("aws s3 cp s3://#{bucket_name.value}/#{test_file} /tmp/#{test_file} --region $(aws s3api get-bucket-location --bucket #{bucket_name.value} --output text)") do
61
+ its( :exit_status ) { should_not eq 0 }
62
+ end
63
+ end
64
+
65
+ end # conttext
66
+
67
+ end
68
+
69
+
70
+
71
+
72
+ end
@@ -0,0 +1,144 @@
1
+ require 'spec_helper'
2
+
3
+ current_test = "S3ReadAccessAllowed"
4
+
5
+ describe current_test do
6
+
7
+ # ------------------------------------------------------------------
8
+ # test parameters
9
+
10
+ bucket_name = test_parameter( current_test, "Bucket" )
11
+
12
+ # bucket_name = stack_output( 'Bucket' ).value
13
+
14
+ # ------------------------------------------------------------------
15
+ # constanst used in test
16
+
17
+ test_file="ttest.tmp"
18
+
19
+ # ------------------------------------------------------------------
20
+ # Test paramters defined
21
+
22
+ describe "Test parameter definition" do
23
+
24
+ describe bucket_name do
25
+ its( :definition_in_test_suite ) { should_not eq nil }
26
+ end
27
+
28
+ end
29
+
30
+ describe "Test parameter values" do
31
+
32
+ describe bucket_name do
33
+ its( :value ) { should_not eq nil }
34
+ end
35
+
36
+ end
37
+
38
+
39
+ # # ------------------------------------------------------------------
40
+ # # Stack parameters && outputs
41
+
42
+ # describe "Stack" do
43
+
44
+ # it "#defines bucket_name" do
45
+ # expect( bucket_name ).not_to eql( nil )
46
+ # end
47
+
48
+ # end
49
+
50
+ # ------------------------------------------------------------------
51
+ # aws Command line interface installed
52
+
53
+ context "Operating system context" do
54
+
55
+ describe "Aws Commad Line Interface (CLI) is installed" do
56
+ describe command('type aws') do
57
+ its( :exit_status ) { should eq 0 }
58
+ end
59
+ end
60
+
61
+ end
62
+
63
+ # ------------------------------------------------------------------
64
+ # Context
65
+
66
+ context "When read access to a S3 bucket granted" do
67
+
68
+ describe "Can list S3 buckets" do
69
+ describe command('aws s3 ls') do
70
+ its( :exit_status ) { should eq 0 }
71
+ end
72
+ end
73
+
74
+ describe "Can list S3 bucket keys" do
75
+ default_ls = "aws s3 ls s3://#{bucket_name.value}"
76
+ region_ls = "aws s3 ls s3://#{bucket_name.value} --region $(aws s3api get-bucket-location --bucket #{bucket_name.value} --output text)"
77
+ describe command( "#{default_ls} || #{region_ls}" ) do
78
+ its ( :exit_status ) { should eq 0 }
79
+ end
80
+ end
81
+
82
+
83
+ context "When an Object exists in S3 bucket" do
84
+
85
+ before(:context) do
86
+ cmd = "echo tst | aws s3 cp - s3://#{bucket_name.value}/#{test_file}"
87
+ `#{cmd}`
88
+ raise "Error in '#{cmd}' " unless $? == 0
89
+ end
90
+
91
+ after(:context) do
92
+ cmd = "aws s3 rm s3://#{bucket_name.value}/#{test_file}"
93
+ `#{cmd}`
94
+ raise "Error in '#{cmd}' " unless $? == 0
95
+ end
96
+
97
+ # Using "serverspec" style here
98
+ describe "Can read the Object from a S3 bucket" do
99
+ default_cp = "aws s3 cp s3://#{bucket_name.value}/#{test_file} /tmp/#{test_file}"
100
+ region_cp = "aws s3 cp s3://#{bucket_name.value}/#{test_file} /tmp/#{test_file} --region $(aws s3api get-bucket-location --bucket #{bucket_name.value} --output text)"
101
+ describe command( "#{default_cp} || #{region_cp}" ) do
102
+ its( :exit_status ) { should eq 0 }
103
+ end
104
+
105
+ end
106
+
107
+ # using subject + expect style
108
+ describe "Cannot modify (= delete) the Object in bucket" do
109
+
110
+ describe command("aws s3 rm s3://#{bucket_name.value}/#{test_file} --region $(aws s3api get-bucket-location --bucket #{bucket_name.value} --output text)") do
111
+ its ( :exit_status ) { should_not eql 0 }
112
+ end
113
+
114
+ end
115
+
116
+ end # context test_file in bucket
117
+
118
+ # subject + it is_expected one liner
119
+ describe "Cannot write to bucket" do
120
+
121
+ describe "Create an Object in bucket should fail" do
122
+ describe command("aws s3 cp /etc/hosts s3://#{bucket_name.value}/#{test_file} --region $(aws s3api get-bucket-location --bucket #{bucket_name.value} --output text)") do
123
+ its( :exit_status ) { should_not eql 0 }
124
+ end
125
+ end
126
+ end
127
+ end
128
+
129
+ # ------------------------------------------------------------------
130
+ #
131
+
132
+ context "When bucket does not exists" do
133
+
134
+ describe "Cannot list S3 bucket keys" do
135
+
136
+ describe command( "aws s3 ls s3://DASKLjwKLJ4534Buckert --region $(aws s3api get-bucket-location --bucket #{@bucket_name} --output text)") do
137
+ its( :exit_status ) { should_not eq 0 }
138
+ end
139
+ end
140
+
141
+ end
142
+
143
+
144
+ end