|
1 | 1 | require "rails_helper" |
2 | 2 |
|
3 | 3 | RSpec.describe AuthController do |
4 | | - describe "#callback" do |
5 | | - let(:integration_key) { "13251241" } |
6 | | - let(:user) { create(:user, stem_user_id: integration_key) } |
7 | | - let(:auth0_hash) { |
8 | | - OmniAuth::AuthHash.new( |
9 | | - provider: "stem", |
10 | | - uid: "auth0|user@example.com", |
11 | | - credentials: { |
12 | | - expires_at: 1_546_601_180, |
13 | | - token: "14849048797785647933" |
14 | | - }, |
15 | | - info: { |
16 | | - achiever_contact_no: "b44cb53f-c690-4535-bd79-89e893337ec6", |
17 | | - first_name: "Jane", |
18 | | - last_name: "Doe", |
19 | | - email: "user@example.com", |
20 | | - stem_user_id: integration_key |
| 4 | + let(:integration_key) { "13251241" } |
| 5 | + let(:user) { create(:user, stem_user_id: integration_key) } |
| 6 | + let(:auth0_hash) { |
| 7 | + OmniAuth::AuthHash.new( |
| 8 | + provider: "stem", |
| 9 | + uid: "auth0|user@example.com", |
| 10 | + credentials: { |
| 11 | + expires_at: 1_546_601_180, |
| 12 | + token: "14849048797785647933" |
| 13 | + }, |
| 14 | + info: { |
| 15 | + achiever_contact_no: "b44cb53f-c690-4535-bd79-89e893337ec6", |
| 16 | + first_name: "Jane", |
| 17 | + last_name: "Doe", |
| 18 | + email: "user@example.com", |
| 19 | + stem_user_id: integration_key |
| 20 | + |
| 21 | + } |
| 22 | + ) |
| 23 | + } |
| 24 | + |
| 25 | + let(:auth0_invalid_hash) { |
| 26 | + OmniAuth::AuthHash.new( |
| 27 | + provider: "stem", |
| 28 | + uid: "auth0|user@example.com", |
| 29 | + credentials: { |
| 30 | + expires_at: 1_546_601_180, |
| 31 | + token: "14849048797785647933" |
| 32 | + }, |
| 33 | + info: { |
| 34 | + achiever_contact_no: nil, |
| 35 | + first_name: "Jane", |
| 36 | + last_name: "Doe", |
| 37 | + email: "user@example.com", |
| 38 | + stem_user_id: nil |
21 | 39 |
|
22 | | - } |
23 | | - ) |
24 | | - } |
| 40 | + } |
| 41 | + ) |
| 42 | + } |
25 | 43 |
|
| 44 | + describe "#callback" do |
26 | 45 | before do |
27 | 46 | OmniAuth.config.test_mode = true |
28 | 47 | OmniAuth.config.mock_auth[:stem] = auth0_hash |
|
53 | 72 | end |
54 | 73 | end |
55 | 74 |
|
| 75 | + context "invalid info" do |
| 76 | + before do |
| 77 | + OmniAuth.config.test_mode = true |
| 78 | + OmniAuth.config.mock_auth[:stem] = auth0_invalid_hash |
| 79 | + end |
| 80 | + |
| 81 | + it "raises exception when data missing" do |
| 82 | + expect { |
| 83 | + get callback_path |
| 84 | + }.to raise_error(StandardError) |
| 85 | + end |
| 86 | + end |
| 87 | + |
56 | 88 | context "when source_uri is not present" do |
57 | 89 | before do |
58 | 90 | OmniAuth.config.test_mode = true |
|
0 commit comments