Skip to content

Commit

Permalink
Remove cookies header from rack_response that was added in v6 release (
Browse files Browse the repository at this point in the history
…#182)

* remove cookies from rack_response

* write tests for rack_response to ensure correct keys are present

* use github action rubygems/release-gem
  • Loading branch information
jeremiahlukus authored Aug 30, 2024
1 parent 4b05f22 commit 0d9b827
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 5 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ⚠️
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
lamby (6.0.0)
lamby (6.0.1)
lambda-console-ruby
rack (>= 3.0.0)

Expand Down
1 change: 0 additions & 1 deletion lib/lamby/handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/lamby/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Lamby
VERSION = '6.0.0'
VERSION = '6.0.1'
end
24 changes: 24 additions & 0 deletions test/handler_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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{<h1>Hello Lamby</h1>}
expect(response.keys).must_equal [:statusCode, :headers, :body]
end

it 'get' do
event = TestHelpers::Events::HttpV2.create
Expand Down Expand Up @@ -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{<h1>Hello Lamby</h1>}
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
Expand Down
4 changes: 2 additions & 2 deletions test/proxy_server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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({})
Expand Down

0 comments on commit 0d9b827

Please sign in to comment.