Skip to content

Commit

Permalink
feat: include tags in the user data inside the request (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
olesyakorovina committed Aug 25, 2021
1 parent 7ee31ad commit 91e9bb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/services/forest_liana/token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def self.create_token(user, rendering_id)
last_name: user['last_name'],
team: user['teams'][0],
role: user['role'],
tags: user['tags'],
rendering_id: rendering_id,
exp: expiration_in_seconds()
}, ForestLiana.auth_secret, 'HS256')
Expand Down
6 changes: 5 additions & 1 deletion spec/requests/authentications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

describe "GET /authentication/callback" do
before() do
response = '{"data":{"id":666,"attributes":{"first_name":"Alice","last_name":"Doe","email":"alice@forestadmin.com","teams":[1,2,3],"role":"Test"}}}'
response = '{"data":{"id":666,"attributes":{"first_name":"Alice","last_name":"Doe","email":"alice@forestadmin.com","teams":[1,2,3],"role":"Test","tags":[{"key":"city","value":"Paris"}]}}}'
allow(ForestLiana::ForestApiRequester).to receive(:get).with(
"/liana/v2/renderings/42/authorization", { :headers => { "forest-token" => "THE-ACCESS-TOKEN" }, :query=> {} }
).and_return(
Expand Down Expand Up @@ -76,6 +76,10 @@
}

expect(decoded).to include(expected_token_data)
tags = decoded['tags']
expect(tags.length).to eq(1)
expect(tags[0]['key']).to eq("city")
expect(tags[0]['value']).to eq("Paris")
expect(body).to eq({ token: token, tokenData: decoded.deep_symbolize_keys! })
expect(response).to have_http_status(200)
end
Expand Down

0 comments on commit 91e9bb9

Please sign in to comment.