diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ca51938 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Release Gem +on: + workflow_dispatch: + branches: + - master + +jobs: + push: + name: Push gem to RubyGems.org + runs-on: ubuntu-latest + + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag + + steps: + # Set up + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: ruby + + # Release + - uses: rubygems/release-gem@v1 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e6be18..adf4373 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ See this http://keepachangelog.com link for information on how we want this docu ## v6.0.0 +- Remove "cookies" header from rack response to conform to Lambda proxy integration requirements. + +## v6.0.0 + ### Changed - ⚠️ Breaking Changes ⚠️ diff --git a/Gemfile.lock b/Gemfile.lock index 2c4f5ef..cb74820 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - lamby (6.0.0) + lamby (6.0.1) lambda-console-ruby rack (>= 3.0.0) diff --git a/lib/lamby/handler.rb b/lib/lamby/handler.rb index 71ea7e7..41793cf 100644 --- a/lib/lamby/handler.rb +++ b/lib/lamby/handler.rb @@ -81,7 +81,6 @@ def rack_option def rack_response { statusCode: status, headers: stringify_values!(headers), - cookies: @set_cookies, body: body }.merge(rack.response(self)) end diff --git a/lib/lamby/version.rb b/lib/lamby/version.rb index ee8d39f..8bf3ad1 100644 --- a/lib/lamby/version.rb +++ b/lib/lamby/version.rb @@ -1,3 +1,3 @@ module Lamby - VERSION = '6.0.0' + VERSION = '6.0.1' end diff --git a/test/handler_test.rb b/test/handler_test.rb index 76942aa..17e861f 100644 --- a/test/handler_test.rb +++ b/test/handler_test.rb @@ -5,7 +5,19 @@ class HandlerTest < LambySpec let(:app) { Rack::Builder.new { run Rails.application }.to_app } let(:context) { TestHelpers::LambdaContext.new } + describe 'http-v2' do + it 'returns the correct rack response' do + event = TestHelpers::Events::HttpV2.create + handler = Lamby::Handler.new(app, event, context, rack: :http) + handler.call + response = handler.send(:rack_response) + + expect(response[:statusCode]).must_equal 200 + expect(response[:headers]['Content-Type']).must_equal 'text/html; charset=utf-8' + expect(response[:body]).must_match %r{

Hello Lamby

} + expect(response.keys).must_equal [:statusCode, :headers, :body] + end it 'get' do event = TestHelpers::Events::HttpV2.create @@ -101,6 +113,18 @@ class HandlerTest < LambySpec describe 'http-v1' do + it 'returns the correct rack response' do + event = TestHelpers::Events::HttpV1.create + handler = Lamby::Handler.new(app, event, context, rack: :http) + handler.call + response = handler.send(:rack_response) + + expect(response[:statusCode]).must_equal 200 + expect(response[:headers]['Content-Type']).must_equal 'text/html; charset=utf-8' + expect(response[:body]).must_match %r{

Hello Lamby

} + expect(response.keys).must_equal [:statusCode, :headers, :body] + end + it 'get' do event = TestHelpers::Events::HttpV1.create result = Lamby.handler app, event, context, rack: :http diff --git a/test/proxy_server_test.rb b/test/proxy_server_test.rb index a88960a..abca7f2 100644 --- a/test/proxy_server_test.rb +++ b/test/proxy_server_test.rb @@ -19,7 +19,7 @@ class ProxyServerTest < LambySpec it 'should call Lamby.cmd on POST and include full response as JSON' do response = post '/', json, 'CONTENT_TYPE' => 'application/json' expect(response.status).must_equal 200 - expect(response.headers).must_equal({"content-type"=>"application/json", "content-length"=>"755"}) + expect(response.headers).must_equal({"content-type"=>"application/json", "content-length"=>"740"}) response_body = JSON.parse(response.body) expect(response_body['statusCode']).must_equal 200 expect(response_body['headers']).must_be_kind_of Hash @@ -42,7 +42,7 @@ class ProxyServerTest < LambySpec Lamby.config.rack_app = rack_app response = post '/', json, 'CONTENT_TYPE' => 'application/json' expect(response.status).must_equal 200 - expect(response.headers).must_equal({"content-type"=>"application/json", "content-length"=>"58"}) + expect(response.headers).must_equal({"content-type"=>"application/json", "content-length"=>"43"}) response_body = JSON.parse(response.body) expect(response_body['statusCode']).must_equal 200 expect(response_body['headers']).must_equal({})