aws-must-templates 0.1.6 → 0.2.1
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.
- checksums.yaml +4 -4
- data/README.md +97 -44
- data/lib/tasks/cross-ref.rb +6 -0
- data/lib/tasks/suite.rake +150 -48
- data/lib/test-suites/test_suites.rb +13 -13
- data/mustache/commonDependsOn.mustache +24 -2
- data/mustache/commonRef.mustache +22 -0
- data/mustache/commonValue.mustache +1 -1
- data/mustache/commonXGressRule.mustache +31 -0
- data/mustache/mapping.mustache +3 -1
- data/mustache/mappingAmazonVpcNat.mustache +38 -0
- data/mustache/resource.mustache +4 -0
- data/mustache/resourceInstance.mustache +26 -7
- data/mustache/resourceInternetGateway.mustache +30 -16
- data/mustache/resourceRoute.mustache +50 -0
- data/mustache/resourceRouteTable.mustache +67 -0
- data/mustache/resourceSecurityGroup.mustache +13 -12
- data/mustache/resourceSubnet.mustache +20 -8
- data/mustache/root.mustache +26 -11
- data/spec/aws-must-templates/AllwaysOk/AllwaysOk_spec.rb +35 -0
- data/spec/aws-must-templates/AwsCommandLineInterfaceInstalled/AwsCommandLineInterfaceInstalled_spec.rb +19 -1
- data/spec/aws-must-templates/AwsMustTestRunnerProperties/AwsMustTestRunnerProperties_spec.rb +16 -1
- data/spec/aws-must-templates/CloudFormationHelperScriptsInstalled/CloudFormationHelperScriptsInstalled_spec.rb +17 -0
- data/spec/aws-must-templates/Ec2InstanceType/Ec2InstanceType_spec.rb +47 -0
- data/spec/aws-must-templates/Ec2PrivateIp/Ec2PrivateIp_spec.rb +49 -0
- data/spec/aws-must-templates/Ec2PublicIp/Ec2PublicIp_spec.rb +68 -0
- data/spec/aws-must-templates/Ec2Routes/Ec2Routes_spec.rb +69 -0
- data/spec/aws-must-templates/Ec2SecurityGroups/Ec2SecurityGroups_spec.rb +151 -0
- data/spec/aws-must-templates/Ec2StatusNormal/Ec2StatusNormal_spec.rb +55 -0
- data/spec/aws-must-templates/NetworkCanPing/NetworkCanPing_spec.rb +36 -0
- data/spec/aws-must-templates/ParameterTest/ParameterTest_spec.rb +17 -1
- data/spec/aws-must-templates/RespondsToPing/RespondsToPing_spec.rb +46 -0
- data/spec/aws-must-templates/S3NoAccess/S3NoAccess_spec.rb +17 -3
- data/spec/aws-must-templates/S3ReadAccessAllowed/S3ReadAccessAllowed_spec.rb +18 -1
- data/spec/aws-must-templates/Stack/Stack_spec.rb +28 -1
- data/spec/aws-must-templates/ValidOSVersion/ValidOSVersion_spec.rb +16 -1
- data/spec/aws-must-templates/Vpc/vpc_spec.rb +51 -0
- data/spec/aws-must-templates/table_of_content.mustache +67 -0
- data/spec/lib/test_suites_spec.rb +101 -28
- data/spec/mustache/commonDependsOn_spec.rb +57 -2
- data/spec/mustache/commonInstanceType_spec.rb +1 -1
- data/spec/mustache/mappingAmazonVpcNat_spec.rb +56 -0
- data/spec/mustache/mapping_spec.rb +48 -7
- data/spec/mustache/resourceInstance_spec.rb +102 -1
- data/spec/mustache/resourceInternetGateway_spec.rb +14 -9
- data/spec/mustache/resourcePolicy_spec.rb +1 -1
- data/spec/mustache/resourceS3Bucket_spec.rb +1 -1
- data/spec/mustache/resourceSecurityGroup_spec.rb +3 -3
- data/spec/mustache/resourceSubnet_spec.rb +50 -3
- data/spec/support/lib/aws/aws.rb +6 -0
- data/spec/support/lib/aws/ec2_resource.rb +177 -0
- data/spec/support/lib/aws/mixin_cidr.rb +18 -0
- data/spec/support/lib/aws/mixin_ec2.rb +53 -0
- data/spec/support/lib/aws/mixin_security_group.rb +15 -0
- data/spec/support/lib/aws/mixin_subnet.rb +77 -0
- data/spec/support/lib/aws/mixin_vpc.rb +10 -0
- data/spec/support/lib/aws/route_resource.rb +86 -0
- data/spec/support/lib/aws/security_group_resource.rb +120 -0
- data/spec/support/lib/aws/vpc_resource.rb +69 -0
- data/spec/support/lib/suite_value.rb +38 -0
- data/spec/support/lib/test_parameter.rb +12 -8
- data/spec/support/lib/valid_property.rb +29 -9
- data/spec/support/spec_helper.rb +75 -44
- data/spec/support/utils.rb +4 -0
- metadata +34 -24
@@ -1,6 +1,21 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="S3ReadAccessAllowed"></a>S3ReadAccessAllowed<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validate that read access to S3 bucket `test_parameter( current_test, "Bucket" )` exists
|
8
|
+
|
9
|
+
+++close+++
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
# +++fold-on+++
|
14
|
+
|
15
|
+
|
1
16
|
require 'spec_helper'
|
2
17
|
|
3
|
-
current_test =
|
18
|
+
current_test = File.basename File.dirname __FILE__
|
4
19
|
|
5
20
|
describe current_test do
|
6
21
|
|
@@ -142,3 +157,5 @@ describe current_test do
|
|
142
157
|
|
143
158
|
|
144
159
|
end
|
160
|
+
|
161
|
+
# +++fold-off+++
|
@@ -1,3 +1,18 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="Stack"></a>Stack<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validate (and document in test report!) properties in
|
8
|
+
`property[:stack_id]`
|
9
|
+
|
10
|
+
+++close+++
|
11
|
+
|
12
|
+
=end
|
13
|
+
|
14
|
+
# +++fold-on+++
|
15
|
+
|
1
16
|
require 'spec_helper'
|
2
17
|
|
3
18
|
|
@@ -7,7 +22,7 @@ require 'spec_helper'
|
|
7
22
|
# Configuration
|
8
23
|
#
|
9
24
|
|
10
|
-
current_test =
|
25
|
+
current_test = File.basename File.dirname __FILE__
|
11
26
|
|
12
27
|
props = {
|
13
28
|
"smoke" => [
|
@@ -21,6 +36,16 @@ props = {
|
|
21
36
|
stack_parameter( "KeyName" ),
|
22
37
|
stack_parameter( "SSHLocation" )
|
23
38
|
],
|
39
|
+
"suite2" => [
|
40
|
+
stack_parameter( "InstanceType" ),
|
41
|
+
stack_parameter( "KeyName" ),
|
42
|
+
stack_parameter( "SSHLocation" ),
|
43
|
+
stack_output( "myFront1" ),
|
44
|
+
stack_output( "myNat" ),
|
45
|
+
stack_output( "InstanceId1" ),
|
46
|
+
stack_output( "InstanceId2" ),
|
47
|
+
stack_output( "MyInternetGw" ),
|
48
|
+
],
|
24
49
|
}
|
25
50
|
# ------------------------------------------------------------------
|
26
51
|
#
|
@@ -47,3 +72,5 @@ describe current_test do
|
|
47
72
|
|
48
73
|
end
|
49
74
|
|
75
|
+
|
76
|
+
# +++fold-off+++
|
@@ -1,6 +1,19 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="ValidOSVersion"></a>ValidOSVersion<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validate that operating system codename == `test_parameter( current_test, "Codename" )`
|
8
|
+
|
9
|
+
+++close+++
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
# +++fold-on+++
|
1
14
|
require 'spec_helper'
|
2
15
|
|
3
|
-
current_test =
|
16
|
+
current_test = File.basename File.dirname __FILE__
|
4
17
|
|
5
18
|
describe current_test do
|
6
19
|
|
@@ -14,3 +27,5 @@ describe current_test do
|
|
14
27
|
end
|
15
28
|
end
|
16
29
|
|
30
|
+
|
31
|
+
# +++fold-off+++
|
@@ -0,0 +1,51 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="Vpc"></a>Vpc<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validates that Vpc tagged with `Name` = `test_parameter( current_test, "VpcName" )`
|
8
|
+
exists, and that it is available.
|
9
|
+
|
10
|
+
|
11
|
+
**Parameters**
|
12
|
+
|
13
|
+
* `test_parameter( current_test, "VpcName" )` : search for Vpc with 'Name' tag
|
14
|
+
|
15
|
+
|
16
|
+
+++close+++
|
17
|
+
|
18
|
+
=end
|
19
|
+
|
20
|
+
# +++fold-on+++
|
21
|
+
|
22
|
+
require 'spec_helper'
|
23
|
+
|
24
|
+
current_test = File.basename File.dirname __FILE__
|
25
|
+
|
26
|
+
describe current_test do
|
27
|
+
|
28
|
+
# ------------------------------------------------------------------
|
29
|
+
# test parameters
|
30
|
+
|
31
|
+
vpcName = test_parameter( current_test, "VpcName" )
|
32
|
+
|
33
|
+
|
34
|
+
# ------------------------------------------------------------------
|
35
|
+
# tests
|
36
|
+
describe "vpc '#{vpcName.value}'" do
|
37
|
+
|
38
|
+
describe vpc_resource_by_name( vpcName.value ) do
|
39
|
+
|
40
|
+
it "#is available Vpc" do
|
41
|
+
expect( subject.is_available?).to eql( true )
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end # instance
|
47
|
+
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
# +++fold-off+++
|
@@ -0,0 +1,67 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
==================================================================
|
4
|
+
Style section
|
5
|
+
==================================================================
|
6
|
+
|
7
|
+
}}
|
8
|
+
|
9
|
+
<style>
|
10
|
+
h1 {
|
11
|
+
color:blue;
|
12
|
+
font-size: 2.5em;
|
13
|
+
}
|
14
|
+
h2 {
|
15
|
+
color:blue;
|
16
|
+
font-size: 1.5em;
|
17
|
+
}
|
18
|
+
h3 {
|
19
|
+
color:blue;
|
20
|
+
font-size: 1.5em;
|
21
|
+
}
|
22
|
+
.navigator {
|
23
|
+
font-size: 0.5em;
|
24
|
+
}
|
25
|
+
body {
|
26
|
+
background-color: LightSlateGray;
|
27
|
+
}
|
28
|
+
/* Support fold-on/fold-off toggle */
|
29
|
+
div.fold {
|
30
|
+
width: 90%; padding: .42rem; border-radius: 5px; margin: 1rem;
|
31
|
+
|
32
|
+
}
|
33
|
+
div.fold div {
|
34
|
+
height: 0px; margin: .2rem; overflow: hidden;
|
35
|
+
}
|
36
|
+
div.toggle ~ div { height: 0px; margin: .2rem; overflow: hidden; }
|
37
|
+
input.toggle:checked ~ div {
|
38
|
+
height: auto;
|
39
|
+
color: white;
|
40
|
+
background: #c6a24b;
|
41
|
+
font-family: monospace;
|
42
|
+
white-space: pre;
|
43
|
+
}
|
44
|
+
</style>
|
45
|
+
|
46
|
+
|
47
|
+
{{!
|
48
|
+
==================================================================
|
49
|
+
CONTENT section
|
50
|
+
==================================================================
|
51
|
+
}}
|
52
|
+
|
53
|
+
|
54
|
+
# <a id="top"/><a href="https://github.com/jarjuk/aws-must-templates">aws-must-templates</a>
|
55
|
+
|
56
|
+
RSPEC -tests for `aws-must-templates`.
|
57
|
+
|
58
|
+
## Table of contents
|
59
|
+
|
60
|
+
<ul>
|
61
|
+
{{# files}}
|
62
|
+
<li><a href="#{{basedir}}">{{basedir}}</a></li>
|
63
|
+
{{/ files}}
|
64
|
+
</ul>
|
65
|
+
|
66
|
+
|
67
|
+
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require_relative "spec_helper.rb"
|
2
3
|
|
3
4
|
require 'yaml'
|
@@ -69,8 +70,8 @@ describe "AwsMustTemplates::TestSuites::TestSuites" do
|
|
69
70
|
expect( @sut ).to respond_to( :suite_role_ids )
|
70
71
|
end
|
71
72
|
|
72
|
-
it "methods '
|
73
|
-
expect( @sut ).to respond_to( :
|
73
|
+
it "methods 'suite_instance_names'" do
|
74
|
+
expect( @sut ).to respond_to( :suite_instance_names )
|
74
75
|
end
|
75
76
|
|
76
77
|
it "methods 'suite_instance_role_ids'" do
|
@@ -90,27 +91,27 @@ describe "AwsMustTemplates::TestSuites::TestSuites" do
|
|
90
91
|
|
91
92
|
it "#nil - when suite not found" do
|
92
93
|
suite_id = "aaa"
|
93
|
-
|
94
|
-
expect( @sut.suite_instance_roles( suite_id,
|
94
|
+
instance_name = "notsucnhcid"
|
95
|
+
expect( @sut.suite_instance_roles( suite_id, instance_name )).to eql( nil )
|
95
96
|
end
|
96
97
|
|
97
98
|
it "#nil - when instance not not found" do
|
98
99
|
suite_id = @suite1.keys.first
|
99
|
-
|
100
|
-
expect( @sut.suite_instance_roles( suite_id,
|
100
|
+
instance_name = "notsucnhcid"
|
101
|
+
expect( @sut.suite_instance_roles( suite_id, instance_name )).to eql( nil )
|
101
102
|
end
|
102
103
|
|
103
104
|
it "#empty array - when no roles defined" do
|
104
105
|
suite_id = @suite3.keys.first
|
105
|
-
|
106
|
-
expect( @sut.suite_instance_roles( suite_id,
|
106
|
+
instance_name = @suite3[suite_id]["instances"][0].keys.first
|
107
|
+
expect( @sut.suite_instance_roles( suite_id, instance_name )).to eql( [] )
|
107
108
|
end
|
108
109
|
|
109
110
|
it "#array of role defs - normal case" do
|
110
111
|
suite_id = @suite3.keys.first
|
111
|
-
|
112
|
+
instance_name = @suite3[suite_id]["instances"][1].keys.first
|
112
113
|
roles_ids = ["role1", "role2", "role3" ]
|
113
|
-
expect( @sut.suite_instance_roles( suite_id,
|
114
|
+
expect( @sut.suite_instance_roles( suite_id, instance_name )).to eql( @suite3_instance2_roles )
|
114
115
|
end
|
115
116
|
|
116
117
|
|
@@ -124,48 +125,48 @@ describe "AwsMustTemplates::TestSuites::TestSuites" do
|
|
124
125
|
|
125
126
|
it "#nil - when suite not found" do
|
126
127
|
suite_id = "aaa"
|
127
|
-
|
128
|
-
expect( @sut.suite_instance_role_ids( suite_id,
|
128
|
+
instance_name = "notsucnhcid"
|
129
|
+
expect( @sut.suite_instance_role_ids( suite_id, instance_name )).to eql( nil )
|
129
130
|
end
|
130
131
|
|
131
132
|
it "#nil - when insance not not found" do
|
132
133
|
suite_id = @suite1.keys.first
|
133
|
-
|
134
|
-
expect( @sut.suite_instance_role_ids( suite_id,
|
134
|
+
instance_name = "notsucnhcid"
|
135
|
+
expect( @sut.suite_instance_role_ids( suite_id, instance_name )).to eql( nil )
|
135
136
|
end
|
136
137
|
|
137
138
|
it "#empty array - when no roles defined" do
|
138
139
|
suite_id = @suite3.keys.first
|
139
|
-
|
140
|
-
expect( @sut.suite_instance_role_ids( suite_id,
|
140
|
+
instance_name = @suite3[suite_id]["instances"][0].keys.first
|
141
|
+
expect( @sut.suite_instance_role_ids( suite_id, instance_name )).to eql( [] )
|
141
142
|
end
|
142
143
|
|
143
144
|
it "#array of role ids - normal case" do
|
144
145
|
suite_id = @suite3.keys.first
|
145
|
-
|
146
|
+
instance_name = @suite3[suite_id]["instances"][1].keys.first
|
146
147
|
roles_ids = ["role1", "role2", "role3" ]
|
147
|
-
expect( @sut.suite_instance_role_ids( suite_id,
|
148
|
+
expect( @sut.suite_instance_role_ids( suite_id, instance_name )).to eql( roles_ids )
|
148
149
|
end
|
149
150
|
|
150
151
|
end
|
151
152
|
|
152
153
|
# ------------------------------------------------------------------
|
153
|
-
#
|
154
|
-
describe "
|
154
|
+
# suite_instance_names
|
155
|
+
describe "suite_instance_names" do
|
155
156
|
|
156
157
|
it "#nil - when suite not found" do
|
157
158
|
suite_id = "aaa"
|
158
|
-
expect( @sut.
|
159
|
+
expect( @sut.suite_instance_names( suite_id )).to eql( nil )
|
159
160
|
end
|
160
161
|
|
161
162
|
it "#empty array - when suite does not have any instances" do
|
162
163
|
suite_id = @suite1.keys.first
|
163
|
-
expect( @sut.
|
164
|
+
expect( @sut.suite_instance_names( suite_id )).to eql( [] )
|
164
165
|
end
|
165
166
|
|
166
|
-
it "#array of
|
167
|
+
it "#array of instance_name - normal case" do
|
167
168
|
suite_id = @suite3.keys.first
|
168
|
-
expect( @sut.
|
169
|
+
expect( @sut.suite_instance_names( suite_id )).to eql( @suite3.values.first["instances"].map { |h| h.keys.first })
|
169
170
|
end
|
170
171
|
|
171
172
|
end
|
@@ -316,13 +317,85 @@ describe "AwsMustTemplates::TestSuites::TestSuites" do
|
|
316
317
|
expect { AwsMustTemplates::TestSuites::TestSuites.new }.to raise_error( /No such file/ )
|
317
318
|
end
|
318
319
|
|
320
|
+
# ------------------------------------------------------------------
|
321
|
+
# load ruby/object
|
322
|
+
|
323
|
+
context "Loads ruby/object" do
|
324
|
+
|
325
|
+
# **********
|
326
|
+
# Define test class constructed in YAML
|
327
|
+
|
328
|
+
module Tst
|
329
|
+
class A
|
330
|
+
attr_reader :apu
|
331
|
+
def initialize( apu )
|
332
|
+
@apu=apu
|
333
|
+
end
|
334
|
+
def to_s
|
335
|
+
puts "A=#{@a}"
|
336
|
+
end
|
337
|
+
def ==(a)
|
338
|
+
# puts "self.apu=#{self.apu} vs. a.apu=#{a.apu} #{self.apu == a.apu}"
|
339
|
+
self.apu == a.apu
|
340
|
+
end
|
341
|
+
def init_with( coder )
|
342
|
+
@apu = coder['apu']
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end;
|
346
|
+
|
347
|
+
# **********
|
348
|
+
before :each do
|
349
|
+
|
350
|
+
yaml_content = <<-EOS
|
351
|
+
- tst-suite1:
|
352
|
+
desc: Fails fast if problems with AWS installation
|
353
|
+
roles:
|
354
|
+
- Test1:
|
355
|
+
param1: A
|
356
|
+
- Test2:
|
357
|
+
param2: !ruby/regexp '/^igw.*/'
|
358
|
+
- Test3:
|
359
|
+
param3: !ruby/object:Tst::A
|
360
|
+
apu: hei
|
361
|
+
|
362
|
+
EOS
|
363
|
+
yaml = YAML.load( yaml_content )
|
364
|
+
# puts "\nyaml=#{yaml}\n"
|
365
|
+
expect( YAML ).to receive(:load_file).with(AwsMustTemplates::TestSuites::SUITE_CONFIGS).and_return( yaml )
|
366
|
+
@test_suites = AwsMustTemplates::TestSuites::TestSuites.new
|
367
|
+
|
368
|
+
@expected = { "param1" => "A", "param2" => "igw-AAA", "param3" => Tst::A.new( "hei") }
|
369
|
+
|
370
|
+
end # before
|
371
|
+
|
372
|
+
# **********
|
373
|
+
# Tests
|
374
|
+
|
375
|
+
it "#loads suite from YAML" do
|
376
|
+
expect( @test_suites.suite_ids()).to eql( ['tst-suite1'] )
|
377
|
+
end
|
378
|
+
|
379
|
+
it "#includes fixed parameter" do
|
380
|
+
expect( @test_suites.suite_roles( "tst-suite1" ).first["Test1"] ).to include( { "param1" =>"A", } )
|
381
|
+
end
|
382
|
+
|
383
|
+
it "#defines include matcher for fixed string " do
|
384
|
+
expect( @expected ).to include( @test_suites.suite_roles( "tst-suite1" ).first["Test1"] )
|
385
|
+
end
|
386
|
+
|
387
|
+
it "#defines include matcher for regexp" do
|
388
|
+
expect( @expected ).to include( @test_suites.suite_roles( "tst-suite1" )[1]["Test2"] )
|
389
|
+
end
|
390
|
+
|
391
|
+
it "#defines include matcher Object" do
|
392
|
+
expect( @expected ).to include( @test_suites.suite_roles( "tst-suite1" )[2]["Test3"] )
|
393
|
+
end
|
394
|
+
|
395
|
+
end # context load/ruby object
|
319
396
|
end
|
320
397
|
|
321
398
|
|
322
|
-
it "#works" do
|
323
|
-
expect( 1 ).to eql( 1 )
|
324
|
-
end
|
325
|
-
|
326
399
|
# ------------------------------------------------------------------
|
327
400
|
# helpers
|
328
401
|
def stub_yaml_file( yaml_text )
|
@@ -21,7 +21,9 @@ describe template_under_test do
|
|
21
21
|
|
22
22
|
describe "Attributes" do
|
23
23
|
|
24
|
-
|
24
|
+
# ------------------------------------------------------------------
|
25
|
+
|
26
|
+
it "#string'" do
|
25
27
|
|
26
28
|
expect_str = <<-EOS
|
27
29
|
, "DependsOn" : "heivaan"
|
@@ -37,13 +39,66 @@ describe template_under_test do
|
|
37
39
|
render_str = @aws_must.generate_str( template_under_test, stub_yaml_file( yaml_text ), {} )
|
38
40
|
|
39
41
|
# debug
|
40
|
-
# puts "
|
42
|
+
# puts "render_str1=#{render_str}"
|
43
|
+
# puts json_sanitize( dummy_element + render_str, nil )
|
44
|
+
|
45
|
+
expect( json_sanitize( dummy_element + render_str, nil )).to eql( json_sanitize( dummy_element + expect_str, nil ))
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
# ------------------------------------------------------------------
|
50
|
+
|
51
|
+
it "#array" do
|
52
|
+
|
53
|
+
expect_str = <<-EOS
|
54
|
+
, "DependsOn" : ["hei", "maailma"]
|
55
|
+
EOS
|
56
|
+
|
57
|
+
yaml_text = <<-EOF
|
58
|
+
DependsOn:
|
59
|
+
- hei
|
60
|
+
- maailma
|
61
|
+
EOF
|
62
|
+
|
63
|
+
# debug
|
64
|
+
# puts json_sanitize( dummy_element + expect_str, nil )
|
65
|
+
|
66
|
+
render_str = @aws_must.generate_str( template_under_test, stub_yaml_file( yaml_text ), {} )
|
67
|
+
|
68
|
+
# debug
|
69
|
+
# puts "render_str2=#{render_str}"
|
41
70
|
# puts json_sanitize( dummy_element + render_str, nil )
|
42
71
|
|
43
72
|
expect( json_sanitize( dummy_element + render_str, nil )).to eql( json_sanitize( dummy_element + expect_str, nil ))
|
44
73
|
|
45
74
|
end
|
46
75
|
|
76
|
+
# ------------------------------------------------------------------
|
77
|
+
|
78
|
+
it "#empty" do
|
79
|
+
|
80
|
+
expect_str = <<-EOS
|
81
|
+
EOS
|
82
|
+
|
83
|
+
yaml_text = <<-EOF
|
84
|
+
apu: koe
|
85
|
+
EOF
|
86
|
+
|
87
|
+
# debug
|
88
|
+
# puts json_sanitize( dummy_element + expect_str, nil )
|
89
|
+
|
90
|
+
render_str = @aws_must.generate_str( template_under_test, stub_yaml_file( yaml_text ), {} )
|
91
|
+
|
92
|
+
# debug
|
93
|
+
# puts "render_str2=#{render_str}"
|
94
|
+
# puts json_sanitize( dummy_element + render_str, nil )
|
95
|
+
|
96
|
+
expect( json_sanitize( dummy_element + render_str, nil )).to eql( json_sanitize( dummy_element + expect_str, nil ))
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
|
47
102
|
|
48
103
|
end # describe "Attributes" do
|
49
104
|
|
@@ -63,7 +63,7 @@ describe template_under_test do
|
|
63
63
|
render_str = @aws_must.generate_str( template_under_test, stub_yaml_file( yaml_text ), {} )
|
64
64
|
|
65
65
|
# debug
|
66
|
-
puts "render_str=#{render_str}"
|
66
|
+
# puts "render_str=#{render_str}"
|
67
67
|
# puts json_sanitize( dummy_element + render_str, nil )
|
68
68
|
|
69
69
|
expect( json_sanitize( dummy_element + render_str, nil )).to eql( json_sanitize( dummy_element + expect_str, nil ))
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
template_under_test = "mappingAmazonVpcNat"
|
4
|
+
|
5
|
+
describe template_under_test do
|
6
|
+
|
7
|
+
|
8
|
+
let( :template_dir ) { "mustache" }
|
9
|
+
|
10
|
+
dummy_element = ''
|
11
|
+
|
12
|
+
|
13
|
+
before :each do
|
14
|
+
@aws_must = AwsMust::AwsMust.new( { :template_path => template_dir } )
|
15
|
+
|
16
|
+
# hide partials
|
17
|
+
allow_any_instance_of( AwsMust::Template ).to receive( :partial ).with( any_args ).and_return( "" )
|
18
|
+
# verify that template_under_test actually used
|
19
|
+
expect_any_instance_of( AwsMust::Template ).to receive( :get_template ).with( template_under_test ).and_call_original
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
it "#outpus mapping table" do
|
25
|
+
name = "koe"
|
26
|
+
expect_str= <<-EOS
|
27
|
+
"#{name}" : {
|
28
|
+
"us-east-1" : { "AMI" : "ami-184dc970" },
|
29
|
+
"us-west-1" : { "AMI" : "ami-a98396ec" },
|
30
|
+
"us-west-2" : { "AMI" : "ami-290f4119" },
|
31
|
+
"eu-west-1" : { "AMI" : "ami-14913f63" },
|
32
|
+
"eu-central-1" : { "AMI" : "ami-ae380eb3" },
|
33
|
+
"sa-east-1" : { "AMI" : "ami-8122969c" },
|
34
|
+
"ap-southeast-1" : { "AMI" : "ami-6aa38238" },
|
35
|
+
"ap-southeast-2" : { "AMI" : "ami-893f53b3" },
|
36
|
+
"ap-northeast-1" : { "AMI" : "ami-27d6e626" }
|
37
|
+
}
|
38
|
+
EOS
|
39
|
+
|
40
|
+
# puts json_sanitize( dummy_element + expect_str, nil )
|
41
|
+
|
42
|
+
yaml_text = <<-EOF
|
43
|
+
Name: #{name}
|
44
|
+
EOF
|
45
|
+
|
46
|
+
render_str = @aws_must.generate_str( template_under_test, stub_yaml_file( yaml_text ), {} )
|
47
|
+
|
48
|
+
# puts "render_str1=#{render_str}"
|
49
|
+
# puts json_sanitize( dummy_element + render_str, nil )
|
50
|
+
|
51
|
+
expect( json_sanitize( render_str, nil )).to eql( json_sanitize( expect_str, nil ))
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
end
|
@@ -6,11 +6,12 @@ describe template_under_test do
|
|
6
6
|
|
7
7
|
let( :template_dir ) { "mustache" }
|
8
8
|
|
9
|
-
|
10
|
-
return JSON.parse( str )
|
11
|
-
end
|
9
|
+
dummy_element = ""
|
12
10
|
|
13
11
|
|
12
|
+
# def json_sanitize( str )
|
13
|
+
# return JSON.parse( str )
|
14
|
+
# end
|
14
15
|
|
15
16
|
before :each do
|
16
17
|
@aws_must = AwsMust::AwsMust.new( { :template_path => template_dir } )
|
@@ -22,22 +23,62 @@ describe template_under_test do
|
|
22
23
|
|
23
24
|
end
|
24
25
|
|
26
|
+
# ------------------------------------------------------------------
|
27
|
+
#
|
28
|
+
it "#AmazonVpcNat" do
|
25
29
|
|
26
|
-
|
30
|
+
stubbed_template = [ '{"Instance": "rendered"}' ]
|
27
31
|
|
28
|
-
expect_str
|
32
|
+
expect_str= "#{stubbed_template.join}"
|
29
33
|
|
30
34
|
yaml_text = <<-EOF
|
35
|
+
AmazonVpcNat: true
|
31
36
|
EOF
|
32
37
|
|
38
|
+
# debug
|
39
|
+
# puts "expect_str=#{expect_str}"
|
40
|
+
# puts json_sanitize( expect_str + dummy_element)
|
41
|
+
|
42
|
+
expect_any_instance_of( AwsMust::Template ).to receive( :partial ).with( :mappingAmazonVpcNat ).once.and_return( *stubbed_template )
|
43
|
+
|
44
|
+
# invoke template
|
33
45
|
render_str = @aws_must.generate_str( template_under_test, stub_yaml_file( yaml_text ), {} )
|
34
|
-
|
46
|
+
|
47
|
+
# debug
|
35
48
|
# puts "render_str=#{render_str}"
|
36
|
-
#
|
49
|
+
# puts json_sanitize( render_str + dummy_element )
|
50
|
+
|
51
|
+
expect( json_sanitize( render_str + dummy_element )).to eql( json_sanitize( expect_str + dummy_element ))
|
37
52
|
|
38
53
|
end
|
39
54
|
|
55
|
+
# ------------------------------------------------------------------
|
56
|
+
|
57
|
+
it "#SubnetConfig" do
|
58
|
+
|
59
|
+
stubbed_template = [ '{"Instance": "rendered"}' ]
|
60
|
+
|
61
|
+
expect_str= "#{stubbed_template.join}"
|
62
|
+
|
63
|
+
yaml_text = <<-EOF
|
64
|
+
SubnetConfig: true
|
65
|
+
EOF
|
66
|
+
|
67
|
+
# debug
|
68
|
+
# puts "expect_str=#{expect_str}"
|
69
|
+
# puts json_sanitize( expect_str + dummy_element)
|
70
|
+
|
71
|
+
expect_any_instance_of( AwsMust::Template ).to receive( :partial ).with( :mappingSubnetConfig ).once.and_return( *stubbed_template )
|
40
72
|
|
73
|
+
# invoke template
|
74
|
+
render_str = @aws_must.generate_str( template_under_test, stub_yaml_file( yaml_text ), {} )
|
75
|
+
|
76
|
+
# debug
|
77
|
+
# puts "render_str=#{render_str}"
|
78
|
+
# puts json_sanitize( render_str + dummy_element )
|
41
79
|
|
80
|
+
expect( json_sanitize( render_str + dummy_element )).to eql( json_sanitize( expect_str + dummy_element ))
|
81
|
+
|
82
|
+
end
|
42
83
|
|
43
84
|
end
|