awspec 1.14.0 → 1.14.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 +5 -5
- data/doc/_resource_types/lambda.md +30 -1
- data/doc/resource_types.md +33 -2
- data/lib/awspec/generator/doc/type/lambda.rb +1 -1
- data/lib/awspec/matcher.rb +5 -0
- data/lib/awspec/matcher/have_env_var.rb +9 -0
- data/lib/awspec/matcher/have_env_var_value.rb +18 -0
- data/lib/awspec/matcher/have_env_vars.rb +5 -0
- data/lib/awspec/stub/lambda.rb +27 -1
- data/lib/awspec/type/base.rb +6 -0
- data/lib/awspec/type/iam_policy.rb +0 -6
- data/lib/awspec/type/lambda.rb +1 -0
- data/lib/awspec/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c4536062b8c2373a53257e7371fd3e64cbd5f72d4723fd9f096a445e356f13a6
|
4
|
+
data.tar.gz: d7229d5dc7402eccf5c1b4606f1ab75284c8d97932e5e894a7d613ae245d07d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b860135847a62df4219e064219985b52b86c31de640414be02c50d24e0a495404dcaf56ceb22002ce563b9e683c1ad2c86127b4272e9f7386142163f579ccca9
|
7
|
+
data.tar.gz: 98835ccad4c01e7cd0f39b643b81ea9d5f00459204822ab9572dec11c9bdbdcd59015e2815a62e9a653271423e3c09f5e3141c867e9d51842d4214b30fef4ae1
|
@@ -6,6 +6,35 @@ describe lambda('my-lambda-function-name') do
|
|
6
6
|
end
|
7
7
|
```
|
8
8
|
|
9
|
+
### have_env_vars
|
10
|
+
|
11
|
+
Useful to validate if there are environment variables configured in the Lambda:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
describe lambda('my-lambda-function-name') do
|
15
|
+
it { should have_env_vars() }
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
### have_env_var
|
20
|
+
|
21
|
+
Useful to validate if there is a specific environment variable declared in the Lambda. You probably will want to use it with `have_env_var_value`.
|
22
|
+
|
23
|
+
## have_env_var_value
|
24
|
+
|
25
|
+
Validates if a specific environment variable has the expected value. More useful to use with `have_env_var` because if the variable isn't available, it will fail without notifying that the variable is missing.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
expected.each_pair do |key, value|
|
29
|
+
context "environment variable #{key}" do
|
30
|
+
it { should have_env_var(key) }
|
31
|
+
it { should have_env_var_value(key, value) }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
`expected` would be a hash that has the environment variables names as keys.
|
37
|
+
|
9
38
|
### have_event_source
|
10
39
|
|
11
|
-
This matcher does not support Amazon S3 event sources
|
40
|
+
This matcher does not support Amazon S3 event sources ([see SDK doc](http://docs.aws.amazon.com/sdkforruby/api/Aws/Lambda/Client.html#list_event_source_mappings-instance_method)).
|
data/doc/resource_types.md
CHANGED
@@ -2017,11 +2017,42 @@ end
|
|
2017
2017
|
```
|
2018
2018
|
|
2019
2019
|
|
2020
|
+
### have_env_var
|
2021
|
+
|
2022
|
+
Useful to validate if there is a specific environment variable declared in the Lambda. You probably will want to use it with `have_env_var_value`.
|
2023
|
+
|
2024
|
+
## have_env_var_value
|
2025
|
+
|
2026
|
+
Validates if a specific environment variable has the expected value. More useful to use with `have_env_var` because if the variable isn't available, it will fail without notifying that the variable is missing.
|
2027
|
+
|
2028
|
+
```ruby
|
2029
|
+
expected.each_pair do |key, value|
|
2030
|
+
context "environment variable #{key}" do
|
2031
|
+
it { should have_env_var(key) }
|
2032
|
+
it { should have_env_var_value(key, value) }
|
2033
|
+
end
|
2034
|
+
end
|
2035
|
+
```
|
2036
|
+
|
2037
|
+
`expected` would be a hash that has the environment variables names as keys.
|
2038
|
+
|
2039
|
+
|
2040
|
+
### have_env_vars
|
2041
|
+
|
2042
|
+
Useful to validate if there are environment variables configured in the Lambda:
|
2043
|
+
|
2044
|
+
```ruby
|
2045
|
+
describe lambda('my-lambda-function-name') do
|
2046
|
+
it { should have_env_vars() }
|
2047
|
+
end
|
2048
|
+
```
|
2049
|
+
|
2050
|
+
|
2020
2051
|
### have_event_source
|
2021
2052
|
|
2022
|
-
This matcher does not support Amazon S3 event sources
|
2053
|
+
This matcher does not support Amazon S3 event sources ([see SDK doc](http://docs.aws.amazon.com/sdkforruby/api/Aws/Lambda/Client.html#list_event_source_mappings-instance_method)).
|
2023
2054
|
|
2024
|
-
### its(:function_name), its(:function_arn), its(:runtime), its(:role), its(:handler), its(:code_size), its(:description), its(:timeout), its(:memory_size), its(:last_modified), its(:code_sha_256), its(:version), its(:vpc_config), its(:dead_letter_config), its(:
|
2055
|
+
### its(:function_name), its(:function_arn), its(:runtime), its(:role), its(:handler), its(:code_size), its(:description), its(:timeout), its(:memory_size), its(:last_modified), its(:code_sha_256), its(:version), its(:vpc_config), its(:dead_letter_config), its(:kms_key_arn), its(:master_arn), its(:revision_id), its(:layers)
|
2025
2056
|
## <a name="launch_configuration">launch_configuration</a>
|
2026
2057
|
|
2027
2058
|
LaunchConfiguration resource type.
|
data/lib/awspec/matcher.rb
CHANGED
@@ -78,3 +78,8 @@ require 'awspec/matcher/have_subscription_attributes'
|
|
78
78
|
# Redshift
|
79
79
|
require 'awspec/matcher/belong_to_cluster_subnet_group'
|
80
80
|
require 'awspec/matcher/have_cluster_parameter_group'
|
81
|
+
|
82
|
+
# Lambda
|
83
|
+
require 'awspec/matcher/have_env_vars'
|
84
|
+
require 'awspec/matcher/have_env_var'
|
85
|
+
require 'awspec/matcher/have_env_var_value'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
RSpec::Matchers.define :have_env_var_value do |env_var, value|
|
2
|
+
match do |lambda_function|
|
3
|
+
if lambda_function.environment.variables.key?(env_var)
|
4
|
+
lambda_function.environment.variables[env_var] == value
|
5
|
+
else
|
6
|
+
false
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
description do
|
11
|
+
"have the value #{value}"
|
12
|
+
end
|
13
|
+
|
14
|
+
failure_message do |lambda_function|
|
15
|
+
current_value = lambda_function.environment.variables[env_var]
|
16
|
+
"Environment variable #{env_var} don't have the value #{value}, but #{current_value}"
|
17
|
+
end
|
18
|
+
end
|
data/lib/awspec/stub/lambda.rb
CHANGED
@@ -10,7 +10,33 @@ Aws.config[:lambda] = {
|
|
10
10
|
handler: 'lambda_function.lambda_handler',
|
11
11
|
timeout: 5,
|
12
12
|
memory_size: 256,
|
13
|
-
code_size: 1234
|
13
|
+
code_size: 1234,
|
14
|
+
last_modified: Time.new(2018, 12, 05, 19, 10, 44, '+00:00'),
|
15
|
+
code_sha_256: 'LAI9GRLpJD/dq2D7Uopwaeh354tsd8fQsSI6eSH0xOIs=',
|
16
|
+
version: '$LATEST',
|
17
|
+
role: 'arn:aws:iam::123456789:role/foobarVPCRole',
|
18
|
+
kms_key_arn: nil,
|
19
|
+
revision_id: '8d01897515-bcb0-43c7-9b14-e6d14fyyff4d',
|
20
|
+
layers: nil,
|
21
|
+
tracing_config:
|
22
|
+
# <struct Aws::Lambda::Types::TracingConfigResponse mode="PassThrough">
|
23
|
+
{
|
24
|
+
mode: 'PassThrough'
|
25
|
+
},
|
26
|
+
environment:
|
27
|
+
# <struct Aws::Lambda::Types::EnvironmentResponse
|
28
|
+
{
|
29
|
+
variables:
|
30
|
+
{
|
31
|
+
'ENDPOINT_URL' => 'https://foobar.sns.us-east-1.vpce.amazonaws.com',
|
32
|
+
'ENV_NAME' => 'QA',
|
33
|
+
'LOG_LEVEL' => 'DEBUG',
|
34
|
+
'FOOBAR_TOPIC' => 'arn:aws:sns:us-east-1:123456789:FoobarManager',
|
35
|
+
'RESOLVER1' => '10.196.138.1',
|
36
|
+
'RESOLVER2' => '10.196.136.2'
|
37
|
+
},
|
38
|
+
error: nil
|
39
|
+
}
|
14
40
|
}
|
15
41
|
]
|
16
42
|
},
|
data/lib/awspec/type/base.rb
CHANGED
data/lib/awspec/type/lambda.rb
CHANGED
data/lib/awspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.14.
|
4
|
+
version: 1.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -492,6 +492,9 @@ files:
|
|
492
492
|
- lib/awspec/matcher/have_cluster_parameter_group.rb
|
493
493
|
- lib/awspec/matcher/have_custom_response_error_code.rb
|
494
494
|
- lib/awspec/matcher/have_db_parameter_group.rb
|
495
|
+
- lib/awspec/matcher/have_env_var.rb
|
496
|
+
- lib/awspec/matcher/have_env_var_value.rb
|
497
|
+
- lib/awspec/matcher/have_env_vars.rb
|
495
498
|
- lib/awspec/matcher/have_inline_policy.rb
|
496
499
|
- lib/awspec/matcher/have_key_policy.rb
|
497
500
|
- lib/awspec/matcher/have_key_schema.rb
|
@@ -688,7 +691,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
688
691
|
version: '0'
|
689
692
|
requirements: []
|
690
693
|
rubyforge_project:
|
691
|
-
rubygems_version: 2.6
|
694
|
+
rubygems_version: 2.7.6
|
692
695
|
signing_key:
|
693
696
|
specification_version: 4
|
694
697
|
summary: RSpec tests for your AWS resources.
|