Skip to content

Commit c8718a0

Browse files
committed
chore: Adding note about testing.
1 parent 30ef54c commit c8718a0

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div align="center">
22

3-
# `elixir-auth-microsoft`
3+
<h1>elixir-auth-microsoft</h1>
44

55
The _easy_ way to add **Microsoft `OAuth` authentication**
66
to your **`Elixir` / `Phoenix`** app.
@@ -19,6 +19,29 @@ Just plug-and-play in **5 mins**.
1919

2020
</div>
2121

22+
- [_Why_? 🤷](#why-)
23+
- [_What_? 💭](#what-)
24+
- [_Who_? 👥](#who-)
25+
- [_How_? ✅](#how-)
26+
- [1. Add the hex package to `deps` 📦](#1-add-the-hex-package-to-deps-)
27+
- [2. Create an App Registration in Azure Active Directory 🆕](#2-create-an-app-registration-in-azure-active-directory-)
28+
- [3. Export Environment / Application Variables](#3-export-environment--application-variables)
29+
- [A note on tenants](#a-note-on-tenants)
30+
- [4. Add a "Sign in with Microsoft" Button to your App](#4-add-a-sign-in-with-microsoft-button-to-your-app)
31+
- [5. Use the Built-in Functions to Authenticate People :shipit:](#5-use-the-built-in-functions-to-authenticate-people-shipit)
32+
- [6. Add the `/auth/microsoft/callback` to `router.ex`](#6-add-the-authmicrosoftcallback-to-routerex)
33+
- [6.1 Give it a try!](#61-give-it-a-try)
34+
- [7. Logging the person out](#7-logging-the-person-out)
35+
- [7.1 Setting up the post-logout redirect URI](#71-setting-up-the-post-logout-redirect-uri)
36+
- [7.2 Add button for person to log out](#72-add-button-for-person-to-log-out)
37+
- [_Done_!](#done)
38+
- [Testing](#testing)
39+
- [Complete Working Demo / Example `Phoenix` App 🚀](#complete-working-demo--example-phoenix-app-)
40+
- [Optimised SVG + CSS Button](#optimised-svg--css-button)
41+
- [Notes 📝](#notes-)
42+
- [Branding Guidelines](#branding-guidelines)
43+
44+
2245
# _Why_? 🤷
2346

2447
Following
@@ -403,6 +426,30 @@ Thank you! 🙏
403426

404427
<br />
405428

429+
430+
## Testing
431+
432+
If you want pre-defined responses without making real requests
433+
when testing,
434+
you can add the following property `httpoison_mock`
435+
in your `test.exs` configuration file.
436+
437+
```elixir
438+
config :elixir_auth_microsoft,
439+
httpoison_mock: true
440+
```
441+
442+
With this setting turned on,
443+
calls will return successful requests
444+
with mock data.
445+
446+
Of course, you could always a mocking library like
447+
[`mox`](https://github.com/dashbitco/mox)
448+
for this.
449+
But if you want a quick way to test your app with this package,
450+
this option may be for you!
451+
452+
406453
## Complete Working Demo / Example `Phoenix` App 🚀
407454

408455
If you get stuck

lib/httpoison_mock.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ defmodule ElixirAuthMicrosoft.HTTPoisonMock do
3838

3939
@doc """
4040
Mocks the `post/3` function from HTTPoison.
41-
It yields a predictable, with always the same access token.
41+
It yields a predictable result, with always the same access token.
4242
"""
4343
@spec post(any, any, any) :: {:ok, %{body: binary}}
4444
def post(_url, _body, _headers) do

0 commit comments

Comments
 (0)