Sha256: c6d25d0efeb8bd40868370a2d0ad29659ae447684a865697ef4e421b7ce48a4d

Contents?: true

Size: 881 Bytes

Versions: 12

Compression:

Stored size: 881 Bytes

Contents

require 'test_helper'
require 'json'

class TestLambdaPermission < Minitest::Test
  def setup
    @template = ::Convection.template do
      description 'Lambda Permission Test Template'

      lambda_permission 'LambdaInvokePermission' do
        action 'lambda:InvokeFunction'
        function_name get_att('MyLambdaFunction', 'Arn')
        principal 's3.amazonaws.com'
        source_account fn_ref('AWS::AccountId')
      end
    end
  end

  def from_json
    JSON.parse(@template.to_json)
  end

  def test_lambda_permission
    # Expected JSON:
    json = from_json['Resources']['LambdaInvokePermission']
    properties = json['Properties']

    assert_equal properties['Action'], 'lambda:InvokeFunction'
    assert_equal properties['FunctionName'], 'Fn::GetAtt' => %w(MyLambdaFunction Arn)
    assert_equal properties['SourceAccount'], 'Ref' => 'AWS::AccountId'
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
convection-0.2.32 test/convection/model/test_permission.rb
convection-0.2.31 test/convection/model/test_permission.rb
convection-0.2.30 test/convection/model/test_permission.rb
convection-0.2.29 test/convection/model/test_permission.rb
convection-0.2.28 test/convection/model/test_permission.rb
convection-0.2.27 test/convection/model/test_permission.rb
convection-0.2.26 test/convection/model/test_permission.rb
convection-0.2.25 test/convection/model/test_permission.rb
convection-0.2.24 test/convection/model/test_permission.rb
convection-0.2.23 test/convection/model/test_permission.rb
convection-0.2.22 test/convection/model/test_permission.rb
convection-0.2.21 test/convection/model/test_permission.rb