Skip to content

Commit 0d9b827

Browse files
Remove cookies header from rack_response that was added in v6 release (#182)
* remove cookies from rack_response * write tests for rack_response to ensure correct keys are present * use github action rubygems/release-gem
1 parent 4b05f22 commit 0d9b827

File tree

7 files changed

+58
-5
lines changed

7 files changed

+58
-5
lines changed

.github/workflows/release.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release Gem
2+
on:
3+
workflow_dispatch:
4+
branches:
5+
- master
6+
7+
jobs:
8+
push:
9+
name: Push gem to RubyGems.org
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
14+
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
15+
16+
steps:
17+
# Set up
18+
- uses: actions/checkout@v4
19+
- name: Set up Ruby
20+
uses: ruby/setup-ruby@v1
21+
with:
22+
bundler-cache: true
23+
ruby-version: ruby
24+
25+
# Release
26+
- uses: rubygems/release-gem@v1

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ See this http://keepachangelog.com link for information on how we want this docu
44

55
## v6.0.0
66

7+
- Remove "cookies" header from rack response to conform to Lambda proxy integration requirements.
8+
9+
## v6.0.0
10+
711
### Changed
812

913
- ⚠️ Breaking Changes ⚠️

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
lamby (6.0.0)
4+
lamby (6.0.1)
55
lambda-console-ruby
66
rack (>= 3.0.0)
77

lib/lamby/handler.rb

-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def rack_option
8181
def rack_response
8282
{ statusCode: status,
8383
headers: stringify_values!(headers),
84-
cookies: @set_cookies,
8584
body: body }.merge(rack.response(self))
8685
end
8786

lib/lamby/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Lamby
2-
VERSION = '6.0.0'
2+
VERSION = '6.0.1'
33
end

test/handler_test.rb

+24
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,19 @@ class HandlerTest < LambySpec
55
let(:app) { Rack::Builder.new { run Rails.application }.to_app }
66
let(:context) { TestHelpers::LambdaContext.new }
77

8+
89
describe 'http-v2' do
10+
it 'returns the correct rack response' do
11+
event = TestHelpers::Events::HttpV2.create
12+
handler = Lamby::Handler.new(app, event, context, rack: :http)
13+
handler.call
14+
response = handler.send(:rack_response)
15+
16+
expect(response[:statusCode]).must_equal 200
17+
expect(response[:headers]['Content-Type']).must_equal 'text/html; charset=utf-8'
18+
expect(response[:body]).must_match %r{<h1>Hello Lamby</h1>}
19+
expect(response.keys).must_equal [:statusCode, :headers, :body]
20+
end
921

1022
it 'get' do
1123
event = TestHelpers::Events::HttpV2.create
@@ -101,6 +113,18 @@ class HandlerTest < LambySpec
101113

102114
describe 'http-v1' do
103115

116+
it 'returns the correct rack response' do
117+
event = TestHelpers::Events::HttpV1.create
118+
handler = Lamby::Handler.new(app, event, context, rack: :http)
119+
handler.call
120+
response = handler.send(:rack_response)
121+
122+
expect(response[:statusCode]).must_equal 200
123+
expect(response[:headers]['Content-Type']).must_equal 'text/html; charset=utf-8'
124+
expect(response[:body]).must_match %r{<h1>Hello Lamby</h1>}
125+
expect(response.keys).must_equal [:statusCode, :headers, :body]
126+
end
127+
104128
it 'get' do
105129
event = TestHelpers::Events::HttpV1.create
106130
result = Lamby.handler app, event, context, rack: :http

test/proxy_server_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ProxyServerTest < LambySpec
1919
it 'should call Lamby.cmd on POST and include full response as JSON' do
2020
response = post '/', json, 'CONTENT_TYPE' => 'application/json'
2121
expect(response.status).must_equal 200
22-
expect(response.headers).must_equal({"content-type"=>"application/json", "content-length"=>"755"})
22+
expect(response.headers).must_equal({"content-type"=>"application/json", "content-length"=>"740"})
2323
response_body = JSON.parse(response.body)
2424
expect(response_body['statusCode']).must_equal 200
2525
expect(response_body['headers']).must_be_kind_of Hash
@@ -42,7 +42,7 @@ class ProxyServerTest < LambySpec
4242
Lamby.config.rack_app = rack_app
4343
response = post '/', json, 'CONTENT_TYPE' => 'application/json'
4444
expect(response.status).must_equal 200
45-
expect(response.headers).must_equal({"content-type"=>"application/json", "content-length"=>"58"})
45+
expect(response.headers).must_equal({"content-type"=>"application/json", "content-length"=>"43"})
4646
response_body = JSON.parse(response.body)
4747
expect(response_body['statusCode']).must_equal 200
4848
expect(response_body['headers']).must_equal({})

0 commit comments

Comments
 (0)