Commit 97e40f8
authored
Fix requiring of oauth2 (#86)
The changes in #83 (which were released in v4.1.0) moved the
`OauthClient` class (which uses the `oauth2` gem) from the Rails
applications into the `rpi_auth` gem. At that point the `oauth2` gem was
made a direct dependency of `rpi_auth` and the direct dependency on
`oauth2` was removed from the Rails applications.
I _think_ this meant that the `oauth2` gem was no longer being required
automatically. And, although individual files in the `oauth2` gem were
being required from individual files in `rpi_auth`, this meant that not
all of the files in `oauth2` were being required. In particular, the
`lib/oauth2.rb` file which defines the top-level `OAuth2` module and the
`OAuth2.config` method was no longer being required. This led to
exceptions like [this one][1] in `experience-cs` when
`RpiAuth::OauthClient#refresh_credentials` was called:
NoMethodError: undefined method 'config' for module OAuth2
This commit changes the require statements to just require `oauth2`
which in turn [requires all the relevant files][2] in the `oauth2` gem.
The require statement in `spec/rpi_auth/oauth_client_spec.rb` is
unnecessary, because it's automatically loading `RpiAuth::OauthClient`
which in turn loads `oauth2`. This should mean we no longer see
exceptions like the one above.
I've tested that this fix works in `experience-cs` in
https://github.com/RaspberryPiFoundation/experience-cs/pull/421 - I ran
the Rails app and triggered a token refresh to check that
`NoMethodError` was no longer being raised.
[1]:
https://raspberrypifoundation.sentry.io/issues/6590882516?project=4508953237651456
[2]:
https://gitlab.com/oauth-xx/oauth2/-/blob/v2.0.9/lib/oauth2.rb?ref_type=tags#L11-23File tree
10 files changed
+16
-11
lines changed- gemfiles
- lib/rpi_auth
- controllers
- spec
- dummy/spec/requests
- rpi_auth
10 files changed
+16
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
16 | 22 | | |
17 | 23 | | |
18 | 24 | | |
| |||
140 | 146 | | |
141 | 147 | | |
142 | 148 | | |
143 | | - | |
| 149 | + | |
| 150 | + | |
144 | 151 | | |
145 | 152 | | |
146 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
0 commit comments