Skip to content

Commit 4834b84

Browse files
committed
02/04: thoughts on testing 3rd-party auth
1 parent ce3a467 commit 4834b84

File tree

1 file changed

+20
-0
lines changed
  • exercises/02.authentication/04.solution.third-party-providers

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
11
# Third-party providers
22

33
- How to test authentication that uses a third-party provider, like GitHub (usually OAuth).
4+
5+
## Approaches
6+
7+
1. Test users. Create an actual user of your third-party server and use their credentials in tests.
8+
- Pros:
9+
- Actual user.
10+
- Running OAuth fully.
11+
- Cons:
12+
- Rigid. Need different user states? Have to create different users.
13+
- Brittle. Some providers dislike automation in general and might block your test user.
14+
1. **API mocking + test data**. Intercept the OAuth flow and respond with mocked data. Requires you to have a mock user, too.
15+
- Pros:
16+
- Full control. Tap into any user/OAuth state/behavior.
17+
- Cons:
18+
- OAuth never really runs (not a bad thing).
19+
- Coupled to the provider. You MUST replicate the network flow + data structures used by the provider in real life. Great if they ship some SDKs or typedefs to help you out. Not so great if you have to type it by hand (risk getting stale).
20+
21+
22+
- https://github.com/epicweb-dev/epic-stack/blob/97135fcd7899cab299b402f36804b0d169e87d9d/tests/e2e/onboarding.test.ts#L197
23+
- https://github.com/epicweb-dev/epic-stack/blob/97135fcd7899cab299b402f36804b0d169e87d9d/tests/mocks/github.ts#L136

0 commit comments

Comments
 (0)