fog-aws 0.5.0 → 0.6.0
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/fog-aws.gemspec +1 -0
- data/lib/fog/aws.rb +18 -6
- data/lib/fog/aws/errors.rb +26 -5
- data/lib/fog/aws/lambda.rb +195 -0
- data/lib/fog/aws/parsers/lambda/base.rb +39 -0
- data/lib/fog/aws/requests/lambda/add_permission.rb +100 -0
- data/lib/fog/aws/requests/lambda/create_event_source_mapping.rb +94 -0
- data/lib/fog/aws/requests/lambda/create_function.rb +146 -0
- data/lib/fog/aws/requests/lambda/delete_event_source_mapping.rb +46 -0
- data/lib/fog/aws/requests/lambda/delete_function.rb +43 -0
- data/lib/fog/aws/requests/lambda/get_event_source_mapping.rb +54 -0
- data/lib/fog/aws/requests/lambda/get_function.rb +74 -0
- data/lib/fog/aws/requests/lambda/get_function_configuration.rb +44 -0
- data/lib/fog/aws/requests/lambda/get_policy.rb +52 -0
- data/lib/fog/aws/requests/lambda/invoke.rb +85 -0
- data/lib/fog/aws/requests/lambda/list_event_source_mappings.rb +69 -0
- data/lib/fog/aws/requests/lambda/list_functions.rb +39 -0
- data/lib/fog/aws/requests/lambda/remove_permission.rb +56 -0
- data/lib/fog/aws/requests/lambda/update_event_source_mapping.rb +86 -0
- data/lib/fog/aws/requests/lambda/update_function_code.rb +75 -0
- data/lib/fog/aws/requests/lambda/update_function_configuration.rb +84 -0
- data/lib/fog/aws/version.rb +1 -1
- data/tests/requests/lambda/function_sample_1.js +9 -0
- data/tests/requests/lambda/function_sample_2.js +9 -0
- data/tests/requests/lambda/function_tests.rb +460 -0
- data/tests/requests/lambda/helper.rb +81 -0
- metadata +38 -2
@@ -0,0 +1,84 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class Lambda
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/lambda/base'
|
6
|
+
|
7
|
+
# Updates the configuration parameters for the specified Lambda function.
|
8
|
+
# http://docs.aws.amazon.com/lambda/latest/dg/API_UpdateFunctionConfiguration.html
|
9
|
+
# ==== Parameters
|
10
|
+
# * FunctionName <~String> - name of the Lambda function.
|
11
|
+
# * Description <~String> - short user-defined function description.
|
12
|
+
# * Handler <~String> - function that Lambda calls to begin executing your function.
|
13
|
+
# * MemorySize <~Integer> - amount of memory, in MB, your Lambda function is given.
|
14
|
+
# * Role <~String> - ARN of the IAM role that Lambda will assume when it executes your function.
|
15
|
+
# * Timeout <~Integer> - function execution time at which AWS Lambda should terminate the function.
|
16
|
+
# ==== Returns
|
17
|
+
# * response<~Excon::Response>:
|
18
|
+
# * body<~Hash>:
|
19
|
+
# * 'CodeSize' <~Integer> - size, in bytes, of the function .zip file you uploaded.
|
20
|
+
# * 'Description' <~String> - user-provided description.
|
21
|
+
# * 'FunctionArn' <~String> - Amazon Resource Name (ARN) assigned to the function.
|
22
|
+
# * 'FunctionName' <~String> - name of the function.
|
23
|
+
# * 'Handler' <~String> - function Lambda calls to begin executing your function.
|
24
|
+
# * 'LastModified' <~Time> - timestamp of the last time you updated the function.
|
25
|
+
# * 'Memorysize' <~String> - memory size, in MB, you configured for the function.
|
26
|
+
# * 'Role' <~String> - ARN of the IAM role that Lambda assumes when it executes your function to access any other AWS resources.
|
27
|
+
# * 'Runtime' <~String> - runtime environment for the Lambda function.
|
28
|
+
# * 'Timeout' <~Integer> - function execution time at which Lambda should terminate the function.
|
29
|
+
def update_function_configuration(params={})
|
30
|
+
function_name = params.delete('FunctionName')
|
31
|
+
|
32
|
+
description = params.delete('Description')
|
33
|
+
handler = params.delete('Handler')
|
34
|
+
memory_size = params.delete('MemorySize')
|
35
|
+
role = params.delete('Role')
|
36
|
+
timeout = params.delete('Timeout')
|
37
|
+
|
38
|
+
update = {}
|
39
|
+
update.merge!('Description' => description) if description
|
40
|
+
update.merge!('Handler' => handler) if handler
|
41
|
+
update.merge!('MemorySize' => memory_size) if memory_size
|
42
|
+
update.merge!('Role' => role) if role
|
43
|
+
update.merge!('Timeout' => timeout) if timeout
|
44
|
+
|
45
|
+
request({
|
46
|
+
:method => 'PUT',
|
47
|
+
:path => "/functions/#{function_name}/versions/HEAD/configuration",
|
48
|
+
:body => Fog::JSON.encode(update),
|
49
|
+
:parser => Fog::AWS::Parsers::Lambda::Base.new
|
50
|
+
}.merge(params))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Mock
|
55
|
+
def update_function_configuration(params={})
|
56
|
+
response = self.get_function_configuration(params)
|
57
|
+
|
58
|
+
function_arn = response.body['FunctionArn']
|
59
|
+
|
60
|
+
description = params.delete('Description')
|
61
|
+
handler = params.delete('Handler')
|
62
|
+
memory_size = params.delete('MemorySize')
|
63
|
+
role = params.delete('Role')
|
64
|
+
timeout = params.delete('Timeout')
|
65
|
+
|
66
|
+
update = {}
|
67
|
+
update.merge!('Description' => description) if description
|
68
|
+
update.merge!('Handler' => handler) if handler
|
69
|
+
update.merge!('MemorySize' => memory_size) if memory_size
|
70
|
+
update.merge!('Role' => role) if role
|
71
|
+
update.merge!('Timeout' => timeout) if timeout
|
72
|
+
|
73
|
+
self.data[:functions][function_arn].merge!(update)
|
74
|
+
|
75
|
+
response = Excon::Response.new
|
76
|
+
response.status = 200
|
77
|
+
response.body = self.data[:functions][function_arn]
|
78
|
+
|
79
|
+
response
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/lib/fog/aws/version.rb
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
console.log('Loading function');
|
2
|
+
|
3
|
+
exports.handler = function(event, context) {
|
4
|
+
console.log('value1 =', event.key1);
|
5
|
+
console.log('value2 =', event.key2);
|
6
|
+
console.log('value3 =', event.key3);
|
7
|
+
context.succeed(event.key1); // Echo back the first key value
|
8
|
+
// context.fail('Something went wrong');
|
9
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
console.log('Loading function');
|
2
|
+
|
3
|
+
exports.handler = function(event, context) {
|
4
|
+
console.log('value1 =', event.key1);
|
5
|
+
console.log('value2 =', event.key2);
|
6
|
+
console.log('value3 =', event.key3);
|
7
|
+
context.succeed(event.key2); // Echo back the second key value
|
8
|
+
// context.fail('Something went wrong');
|
9
|
+
};
|
@@ -0,0 +1,460 @@
|
|
1
|
+
Shindo.tests('AWS::Lambda | function requests', ['aws', 'lambda']) do
|
2
|
+
|
3
|
+
_lambda = Fog::AWS[:lambda]
|
4
|
+
account_id = _lambda.account_id
|
5
|
+
region = _lambda.region
|
6
|
+
|
7
|
+
function1 = IO.read(AWS::Lambda::Samples::FUNCTION_1)
|
8
|
+
function2 = IO.read(AWS::Lambda::Samples::FUNCTION_2)
|
9
|
+
zipped_function1 = Base64::encode64(AWS::Lambda::Formats.zip(function1))
|
10
|
+
zipped_function2 = Base64::encode64(AWS::Lambda::Formats.zip(function2))
|
11
|
+
|
12
|
+
function1_arn = nil
|
13
|
+
function1_name = 'function1'
|
14
|
+
function2_name = 'function2'
|
15
|
+
function1_handler = 'index.handler'
|
16
|
+
|
17
|
+
function_role = 'arn:aws:iam::647975416665:role/lambda_basic_execution'
|
18
|
+
|
19
|
+
sns_principal = 'sns.amazonaws.com'
|
20
|
+
sns_topic_sid = Fog::Mock.random_letters_and_numbers(32)
|
21
|
+
sns_allowed_action = 'lambda:invoke'
|
22
|
+
sns_topic_arn = Fog::AWS::Mock.arn('sns', account_id, 'mock_topic', region)
|
23
|
+
|
24
|
+
kinesis_stream_arn = Fog::AWS::Mock.arn('kinesis', account_id, 'mock_stream', region)
|
25
|
+
event_source_mapping1_id = nil
|
26
|
+
|
27
|
+
tests('success') do
|
28
|
+
|
29
|
+
tests('#list_functions').formats(AWS::Lambda::Formats::LIST_FUNCTIONS) do
|
30
|
+
result = _lambda.list_functions.body
|
31
|
+
functions = result['Functions']
|
32
|
+
returns(true) { functions.empty? }
|
33
|
+
result
|
34
|
+
end
|
35
|
+
|
36
|
+
tests('#create_function').formats(AWS::Lambda::Formats::CREATE_FUNCTION) do
|
37
|
+
description = 'a copy of my first function'
|
38
|
+
|
39
|
+
result = _lambda.create_function(
|
40
|
+
'FunctionName' => function1_name,
|
41
|
+
'Handler' => function1_handler,
|
42
|
+
'Role' => function_role,
|
43
|
+
'Description' => description,
|
44
|
+
'Code' => { 'ZipFile' => zipped_function1 }
|
45
|
+
).body
|
46
|
+
|
47
|
+
returns(true) { result.has_key?('FunctionArn') }
|
48
|
+
returns(true) { result['CodeSize'] > 0 }
|
49
|
+
returns(true) { result['MemorySize'] >= 128 }
|
50
|
+
returns(true) { result['FunctionName'].eql?(function1_name) }
|
51
|
+
returns(true) { result['Handler'].eql?(function1_handler) }
|
52
|
+
|
53
|
+
function1_arn = result['FunctionArn']
|
54
|
+
result
|
55
|
+
end
|
56
|
+
|
57
|
+
tests('#invoke') do
|
58
|
+
payload = { 'value1' => 2, 'value2' => 42 }
|
59
|
+
|
60
|
+
result = _lambda.invoke(
|
61
|
+
'FunctionName' => function1_name,
|
62
|
+
'Payload' => payload
|
63
|
+
).body
|
64
|
+
|
65
|
+
returns(false) { result.length.zero? }
|
66
|
+
returns(false) { result.match(/function:#{function1_name} was invoked/).nil? }
|
67
|
+
|
68
|
+
result
|
69
|
+
end
|
70
|
+
|
71
|
+
tests('#get_function').formats(AWS::Lambda::Formats::GET_FUNCTION) do
|
72
|
+
result = _lambda.get_function('FunctionName' => function1_name).body
|
73
|
+
func_config = result['Configuration']
|
74
|
+
|
75
|
+
returns(false) { result['Code']['Location'].match(/^https:\/\/awslambda-/).nil? }
|
76
|
+
returns(true) { func_config.has_key?('FunctionArn') }
|
77
|
+
returns(true) { func_config['CodeSize'] > 0 }
|
78
|
+
returns(true) { func_config['MemorySize'] >= 128 }
|
79
|
+
returns(true) { func_config['FunctionName'].eql?(function1_name) }
|
80
|
+
returns(true) { func_config['Handler'].eql?(function1_handler) }
|
81
|
+
returns(true) { func_config['FunctionArn'].eql?(function1_arn) }
|
82
|
+
|
83
|
+
result
|
84
|
+
end
|
85
|
+
|
86
|
+
tests('#get_function_configuration').formats(AWS::Lambda::Formats::GET_FUNCTION_CONFIGURATION) do
|
87
|
+
result = _lambda.get_function_configuration(
|
88
|
+
'FunctionName' => function1_name).body
|
89
|
+
|
90
|
+
returns(true) { result.has_key?('FunctionArn') }
|
91
|
+
returns(true) { result['CodeSize'] > 0 }
|
92
|
+
returns(true) { result['MemorySize'] >= 128 }
|
93
|
+
returns(true) { result['FunctionName'].eql?(function1_name) }
|
94
|
+
returns(true) { result['Handler'].eql?(function1_handler) }
|
95
|
+
returns(true) { result['FunctionArn'].eql?(function1_arn) }
|
96
|
+
|
97
|
+
result
|
98
|
+
end
|
99
|
+
|
100
|
+
tests('#update_function_configuration').formats(AWS::Lambda::Formats::UPDATE_FUNCTION_CONFIGURATION) do
|
101
|
+
new_memory_size = 256
|
102
|
+
new_description = "this function does nothing, just let's call it foobar"
|
103
|
+
new_timeout = 10
|
104
|
+
|
105
|
+
result = _lambda.update_function_configuration(
|
106
|
+
'FunctionName' => function1_name,
|
107
|
+
'MemorySize' => new_memory_size,
|
108
|
+
'Description' => new_description,
|
109
|
+
'Timeout' => new_timeout
|
110
|
+
).body
|
111
|
+
|
112
|
+
returns(true) { result['CodeSize'] > 0 }
|
113
|
+
returns(true) { result['MemorySize'].eql?(new_memory_size) }
|
114
|
+
returns(true) { result['FunctionArn'].eql?(function1_arn) }
|
115
|
+
returns(true) { result['Description'].eql?(new_description) }
|
116
|
+
returns(true) { result['Timeout'].eql?(new_timeout) }
|
117
|
+
|
118
|
+
result
|
119
|
+
end
|
120
|
+
|
121
|
+
tests('#update_function_code').formats(AWS::Lambda::Formats::UPDATE_FUNCTION_CODE) do
|
122
|
+
result = _lambda.update_function_code(
|
123
|
+
'FunctionName' => function1_name,
|
124
|
+
'ZipFile' => zipped_function2
|
125
|
+
).body
|
126
|
+
|
127
|
+
returns(true) { result.has_key?('FunctionArn') }
|
128
|
+
returns(true) { result['CodeSize'] > 0 }
|
129
|
+
returns(true) { result['MemorySize'] >= 128 }
|
130
|
+
returns(true) { result['FunctionName'].eql?(function1_name) }
|
131
|
+
returns(true) { result['Handler'].eql?(function1_handler) }
|
132
|
+
|
133
|
+
result
|
134
|
+
end
|
135
|
+
|
136
|
+
tests('#add_permission').formats(AWS::Lambda::Formats::ADD_PERMISSION) do
|
137
|
+
params = {
|
138
|
+
'FunctionName' => function1_name,
|
139
|
+
'Principal' => sns_principal,
|
140
|
+
'StatementId' => sns_topic_sid,
|
141
|
+
'Action' => sns_allowed_action,
|
142
|
+
'SourceArn' => sns_topic_arn
|
143
|
+
}
|
144
|
+
result = _lambda.add_permission(params).body
|
145
|
+
statement = result['Statement']
|
146
|
+
|
147
|
+
returns(true) { statement['Action'].include?(sns_allowed_action) }
|
148
|
+
returns(true) { statement['Principal']['Service'].eql?(sns_principal) }
|
149
|
+
returns(true) { statement['Sid'].eql?(sns_topic_sid) }
|
150
|
+
returns(true) { statement['Resource'].eql?(function1_arn) }
|
151
|
+
returns(true) { statement['Effect'].eql?('Allow') }
|
152
|
+
returns(false) { statement['Condition'].empty? }
|
153
|
+
|
154
|
+
result
|
155
|
+
end
|
156
|
+
|
157
|
+
tests('#get_policy').formats(AWS::Lambda::Formats::GET_POLICY) do
|
158
|
+
result = _lambda.get_policy('FunctionName' => function1_name).body
|
159
|
+
policy = result['Policy']
|
160
|
+
|
161
|
+
returns(false) { policy['Statement'].empty? }
|
162
|
+
|
163
|
+
statement = policy['Statement'].first
|
164
|
+
|
165
|
+
returns(true) { statement['Action'].include?(sns_allowed_action) }
|
166
|
+
returns(true) { statement['Principal']['Service'].eql?(sns_principal) }
|
167
|
+
returns(true) { statement['Sid'].eql?(sns_topic_sid) }
|
168
|
+
returns(true) { statement['Resource'].eql?(function1_arn) }
|
169
|
+
returns(true) { statement['Effect'].eql?('Allow') }
|
170
|
+
returns(false) { statement['Condition'].empty? }
|
171
|
+
|
172
|
+
result
|
173
|
+
end
|
174
|
+
|
175
|
+
tests('#remove_permission') do
|
176
|
+
params = {
|
177
|
+
'FunctionName' => function1_name,
|
178
|
+
'StatementId' => sns_topic_sid
|
179
|
+
}
|
180
|
+
result = _lambda.remove_permission(params).body
|
181
|
+
|
182
|
+
returns(true) { result.empty? }
|
183
|
+
|
184
|
+
raises(Fog::AWS::Lambda::Error) do
|
185
|
+
_lambda.get_policy('FunctionName' => function1_name)
|
186
|
+
end
|
187
|
+
|
188
|
+
result
|
189
|
+
end
|
190
|
+
|
191
|
+
tests('#create_event_source_mapping').formats(AWS::Lambda::Formats::CREATE_EVENT_SOURCE_MAPPING) do
|
192
|
+
params = {
|
193
|
+
'FunctionName' => function1_name,
|
194
|
+
'EventSourceArn' => kinesis_stream_arn,
|
195
|
+
'Enabled' => true,
|
196
|
+
'StartingPosition' => 'TRIM_HORIZON'
|
197
|
+
}
|
198
|
+
result = _lambda.create_event_source_mapping(params).body
|
199
|
+
|
200
|
+
returns(true) { result['BatchSize'] > 0 }
|
201
|
+
returns(true) { result['EventSourceArn'].eql?(kinesis_stream_arn) }
|
202
|
+
returns(true) { result['FunctionArn'].eql?(function1_arn) }
|
203
|
+
returns(true) { result['LastProcessingResult'].eql?('No records processed') }
|
204
|
+
returns(true) { result['State'].eql?('Creating') }
|
205
|
+
returns(true) { result['StateTransitionReason'].eql?('User action') }
|
206
|
+
|
207
|
+
event_source_mapping1_id = result['UUID']
|
208
|
+
result
|
209
|
+
end
|
210
|
+
|
211
|
+
tests('#list_event_source_mappings').formats(AWS::Lambda::Formats::LIST_EVENT_SOURCE_MAPPINGS) do
|
212
|
+
params = { 'FunctionName' => function1_name }
|
213
|
+
result = _lambda.list_event_source_mappings(params).body
|
214
|
+
event_source_mappings = result['EventSourceMappings']
|
215
|
+
returns(false) { event_source_mappings.empty? }
|
216
|
+
mapping = event_source_mappings.first
|
217
|
+
returns(true) { mapping['UUID'].eql?(event_source_mapping1_id) }
|
218
|
+
result
|
219
|
+
end
|
220
|
+
|
221
|
+
tests('#get_event_source_mapping').formats(AWS::Lambda::Formats::GET_EVENT_SOURCE_MAPPING) do
|
222
|
+
params = { 'UUID' => event_source_mapping1_id }
|
223
|
+
result = _lambda.get_event_source_mapping(params).body
|
224
|
+
|
225
|
+
returns(true) { result['BatchSize'] > 0 }
|
226
|
+
returns(true) { result['EventSourceArn'].eql?(kinesis_stream_arn) }
|
227
|
+
returns(true) { result['FunctionArn'].eql?(function1_arn) }
|
228
|
+
returns(true) { result['LastProcessingResult'].eql?('OK') }
|
229
|
+
returns(true) { result['State'].eql?('Enabled') }
|
230
|
+
returns(true) { result['StateTransitionReason'].eql?('User action') }
|
231
|
+
returns(true) { result['UUID'].eql?(event_source_mapping1_id) }
|
232
|
+
|
233
|
+
result
|
234
|
+
end
|
235
|
+
|
236
|
+
tests('#update_event_source_mapping').formats(AWS::Lambda::Formats::UPDATE_EVENT_SOURCE_MAPPING) do
|
237
|
+
new_batch_size = 500
|
238
|
+
enabled_mapping = false
|
239
|
+
params = {
|
240
|
+
'UUID' => event_source_mapping1_id,
|
241
|
+
'BatchSize' => new_batch_size,
|
242
|
+
'Enabled' => enabled_mapping
|
243
|
+
}
|
244
|
+
result = _lambda.update_event_source_mapping(params).body
|
245
|
+
|
246
|
+
returns(true) { result['BatchSize'].eql?(new_batch_size) }
|
247
|
+
returns(true) { result['EventSourceArn'].eql?(kinesis_stream_arn) }
|
248
|
+
returns(true) { result['FunctionArn'].eql?(function1_arn) }
|
249
|
+
returns(true) { result['LastProcessingResult'].eql?('OK') }
|
250
|
+
returns(true) { result['State'].eql?('Disabling') }
|
251
|
+
returns(true) { result['StateTransitionReason'].eql?('User action') }
|
252
|
+
returns(true) { result['UUID'].eql?(event_source_mapping1_id) }
|
253
|
+
|
254
|
+
result
|
255
|
+
end
|
256
|
+
|
257
|
+
tests('#delete_event_source_mapping').formats(AWS::Lambda::Formats::DELETE_EVENT_SOURCE_MAPPING) do
|
258
|
+
params = { 'UUID' => event_source_mapping1_id }
|
259
|
+
result = _lambda.delete_event_source_mapping(params).body
|
260
|
+
returns(true) { result['BatchSize'] > 0 }
|
261
|
+
returns(true) { result['EventSourceArn'].eql?(kinesis_stream_arn) }
|
262
|
+
returns(true) { result['FunctionArn'].eql?(function1_arn) }
|
263
|
+
returns(false) { result['LastProcessingResult'].empty? }
|
264
|
+
returns(true) { result['State'].eql?('Deleting') }
|
265
|
+
returns(true) { result['StateTransitionReason'].eql?('User action') }
|
266
|
+
returns(true) { result['UUID'].eql?(event_source_mapping1_id) }
|
267
|
+
result
|
268
|
+
end
|
269
|
+
|
270
|
+
tests('#list_event_source_mappings again').formats(AWS::Lambda::Formats::LIST_EVENT_SOURCE_MAPPINGS) do
|
271
|
+
params = { 'FunctionName' => function1_name }
|
272
|
+
result = _lambda.list_event_source_mappings(params).body
|
273
|
+
event_source_mappings = result['EventSourceMappings']
|
274
|
+
returns(true) { event_source_mappings.empty? }
|
275
|
+
result
|
276
|
+
end
|
277
|
+
|
278
|
+
tests('#delete_function') do
|
279
|
+
result = _lambda.delete_function('FunctionName' => function1_name).body
|
280
|
+
|
281
|
+
returns(true) { result.empty? }
|
282
|
+
|
283
|
+
raises(Fog::AWS::Lambda::Error) do
|
284
|
+
_lambda.get_function('FunctionName' => function1_name)
|
285
|
+
end
|
286
|
+
|
287
|
+
result
|
288
|
+
end
|
289
|
+
|
290
|
+
tests('#list_functions again').formats(AWS::Lambda::Formats::LIST_FUNCTIONS) do
|
291
|
+
result = _lambda.list_functions.body
|
292
|
+
functions = result['Functions']
|
293
|
+
returns(true) { functions.empty? }
|
294
|
+
result
|
295
|
+
end
|
296
|
+
|
297
|
+
tests('#create_function for failures tests').formats(AWS::Lambda::Formats::CREATE_FUNCTION) do
|
298
|
+
description = 'failure tests function'
|
299
|
+
|
300
|
+
result = _lambda.create_function(
|
301
|
+
'FunctionName' => function2_name,
|
302
|
+
'Handler' => function1_handler,
|
303
|
+
'Role' => function_role,
|
304
|
+
'Description' => description,
|
305
|
+
'Code' => { 'ZipFile' => zipped_function1 }
|
306
|
+
).body
|
307
|
+
|
308
|
+
returns(true) { result.has_key?('FunctionArn') }
|
309
|
+
returns(true) { result['CodeSize'] > 0 }
|
310
|
+
returns(true) { result['MemorySize'] >= 128 }
|
311
|
+
returns(true) { result['FunctionName'].eql?(function2_name) }
|
312
|
+
returns(true) { result['Handler'].eql?(function1_handler) }
|
313
|
+
|
314
|
+
result
|
315
|
+
end
|
316
|
+
|
317
|
+
end
|
318
|
+
|
319
|
+
tests('failures') do
|
320
|
+
|
321
|
+
tests("#invoke without function name").raises(Fog::AWS::Lambda::Error) do
|
322
|
+
response = _lambda.invoke.body
|
323
|
+
end
|
324
|
+
|
325
|
+
tests("#invoke nonexistent function").raises(Fog::AWS::Lambda::Error) do
|
326
|
+
response = Fog::AWS[:lambda].invoke('FunctionName' => 'nonexistent').body
|
327
|
+
end
|
328
|
+
|
329
|
+
tests("#get_function without function name").raises(Fog::AWS::Lambda::Error) do
|
330
|
+
response = _lambda.get_function.body
|
331
|
+
end
|
332
|
+
|
333
|
+
tests("#get_function on nonexistent function").raises(Fog::AWS::Lambda::Error) do
|
334
|
+
response = _lambda.get_function('FunctionName' => 'nonexistent').body
|
335
|
+
end
|
336
|
+
|
337
|
+
tests("#get_function_configuration without function name").raises(Fog::AWS::Lambda::Error) do
|
338
|
+
response = _lambda.get_function_configuration.body
|
339
|
+
end
|
340
|
+
|
341
|
+
tests("#get_function_configuration on nonexistent function").raises(Fog::AWS::Lambda::Error) do
|
342
|
+
response = _lambda.get_function_configuration('FunctionName' => 'nonexistent').body
|
343
|
+
end
|
344
|
+
|
345
|
+
tests("update_function_configuration without function name").raises(Fog::AWS::Lambda::Error) do
|
346
|
+
response = _lambda.update_function_configuration.body
|
347
|
+
end
|
348
|
+
|
349
|
+
tests("#update_function_configuration on nonexistent function").raises(Fog::AWS::Lambda::Error) do
|
350
|
+
response = _lambda.update_function_configuration('FunctionName' => 'nonexistent').body
|
351
|
+
end
|
352
|
+
|
353
|
+
tests("update_function_code without function name").raises(Fog::AWS::Lambda::Error) do
|
354
|
+
response = _lambda.update_function_code.body
|
355
|
+
end
|
356
|
+
|
357
|
+
tests("#update_function_code on nonexistent function").raises(Fog::AWS::Lambda::Error) do
|
358
|
+
response = _lambda.update_function_code(
|
359
|
+
'FunctionName' => 'nonexistent',
|
360
|
+
'ZipFile' => zipped_function2
|
361
|
+
).body
|
362
|
+
end
|
363
|
+
|
364
|
+
tests("#update_function_code on valid function without source").raises(Fog::AWS::Lambda::Error) do
|
365
|
+
response = _lambda.update_function_code('FunctionName' => 'foobar').body
|
366
|
+
end
|
367
|
+
|
368
|
+
tests("#delete_function without params").raises(Fog::AWS::Lambda::Error) do
|
369
|
+
response = _lambda.delete_function.body
|
370
|
+
end
|
371
|
+
|
372
|
+
tests("#delete_function on nonexistent function").raises(Fog::AWS::Lambda::Error) do
|
373
|
+
response = _lambda.delete_function('FunctionName' => 'nonexistent').body
|
374
|
+
end
|
375
|
+
|
376
|
+
tests('#get_policy without params').raises(Fog::AWS::Lambda::Error) do
|
377
|
+
response = _lambda.get_policy.body
|
378
|
+
end
|
379
|
+
|
380
|
+
tests('#get_policy on nonexistent function').raises(Fog::AWS::Lambda::Error) do
|
381
|
+
response = _lambda.get_policy('FunctionName' => 'nonexistent').body
|
382
|
+
end
|
383
|
+
|
384
|
+
tests('#get_policy on function without permissions').raises(Fog::AWS::Lambda::Error) do
|
385
|
+
response = _lambda.get_policy('FunctionName' => function2_name).body
|
386
|
+
end
|
387
|
+
|
388
|
+
tests('#add_permission without params').raises(Fog::AWS::Lambda::Error) do
|
389
|
+
response = _lambda.add_permission.body
|
390
|
+
end
|
391
|
+
|
392
|
+
tests('#add_permission on nonexistent function').raises(Fog::AWS::Lambda::Error) do
|
393
|
+
response = _lambda.add_permission('FunctionName' => 'nonexistent').body
|
394
|
+
end
|
395
|
+
|
396
|
+
tests('#add_permission with missing params').raises(Fog::AWS::Lambda::Error) do
|
397
|
+
response = _lambda.add_permission('FunctionName' => function2_name).body
|
398
|
+
end
|
399
|
+
|
400
|
+
tests('#remove_permission without params').raises(Fog::AWS::Lambda::Error) do
|
401
|
+
response = _lambda.remove_permission.body
|
402
|
+
end
|
403
|
+
|
404
|
+
tests('#remove_permission on nonexistent function').raises(Fog::AWS::Lambda::Error) do
|
405
|
+
response = _lambda.remove_permission('FunctionName' => 'nonexistent').body
|
406
|
+
end
|
407
|
+
|
408
|
+
tests('#remove_permission on function with missing sid param').raises(Fog::AWS::Lambda::Error) do
|
409
|
+
response = _lambda.get_policy('FunctionName' => function2_name).body
|
410
|
+
end
|
411
|
+
|
412
|
+
tests('#remove_permission on function with missing sid param').raises(Fog::AWS::Lambda::Error) do
|
413
|
+
response = _lambda.get_policy(
|
414
|
+
'FunctionName' => function2_name,
|
415
|
+
'StatementId' => 'nonexistent_statement_id'
|
416
|
+
).body
|
417
|
+
end
|
418
|
+
|
419
|
+
tests('#create_event_source_mapping without params').raises(Fog::AWS::Lambda::Error) do
|
420
|
+
response = _lambda.create_event_source_mapping.body
|
421
|
+
end
|
422
|
+
|
423
|
+
tests('#create_event_source_mapping on nonexistent function').raises(Fog::AWS::Lambda::Error) do
|
424
|
+
response = _lambda.create_event_source_mapping('FunctionName' => 'nonexistent').body
|
425
|
+
end
|
426
|
+
|
427
|
+
tests('#create_event_source_mapping with missing params').raises(Fog::AWS::Lambda::Error) do
|
428
|
+
response = _lambda.create_event_source_mapping('FunctionName' => function2_name).body
|
429
|
+
end
|
430
|
+
|
431
|
+
tests('#get_event_source_mapping without params').raises(Fog::AWS::Lambda::Error) do
|
432
|
+
response = _lambda.get_event_source_mapping.body
|
433
|
+
end
|
434
|
+
|
435
|
+
tests('#get_event_source_mapping nonexistent').raises(Fog::AWS::Lambda::Error) do
|
436
|
+
mapping_id = "deadbeef-caca-cafe-cafa-ffffdeadbeef"
|
437
|
+
response = _lambda.get_event_source_mapping('UUID' => mapping_id).body
|
438
|
+
end
|
439
|
+
|
440
|
+
tests('#update_event_source_mapping without params').raises(Fog::AWS::Lambda::Error) do
|
441
|
+
response = _lambda.update_event_source_mapping.body
|
442
|
+
end
|
443
|
+
|
444
|
+
tests('#update_event_source_mapping nonexistent').raises(Fog::AWS::Lambda::Error) do
|
445
|
+
mapping_id = "deadbeef-caca-cafe-cafa-ffffdeadbeef"
|
446
|
+
response = _lambda.update_event_source_mapping('UUID' => mapping_id).body
|
447
|
+
end
|
448
|
+
|
449
|
+
tests('#delete_event_source_mapping without params').raises(Fog::AWS::Lambda::Error) do
|
450
|
+
response = _lambda.delete_event_source_mapping.body
|
451
|
+
end
|
452
|
+
|
453
|
+
tests('#delete_event_source_mapping nonexistent').raises(Fog::AWS::Lambda::Error) do
|
454
|
+
mapping_id = "deadbeef-caca-cafe-cafa-ffffdeadbeef"
|
455
|
+
response = _lambda.create_event_source_mapping('UUID' => mapping_id).body
|
456
|
+
end
|
457
|
+
|
458
|
+
end
|
459
|
+
|
460
|
+
end
|