Skip to content

Commit

Permalink
chore: Adding note about testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
LuchoTurtle committed Feb 8, 2024
1 parent 30ef54c commit c8718a0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">

# `elixir-auth-microsoft`
<h1>elixir-auth-microsoft</h1>

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

</div>

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


# _Why_? 🤷

Following
Expand Down Expand Up @@ -403,6 +426,30 @@ Thank you! 🙏

<br />


## Testing

If you want pre-defined responses without making real requests
when testing,
you can add the following property `httpoison_mock`
in your `test.exs` configuration file.

```elixir
config :elixir_auth_microsoft,
httpoison_mock: true
```

With this setting turned on,
calls will return successful requests
with mock data.

Of course, you could always a mocking library like
[`mox`](https://github.com/dashbitco/mox)
for this.
But if you want a quick way to test your app with this package,
this option may be for you!


## Complete Working Demo / Example `Phoenix` App 🚀

If you get stuck
Expand Down
2 changes: 1 addition & 1 deletion lib/httpoison_mock.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ defmodule ElixirAuthMicrosoft.HTTPoisonMock do

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

0 comments on commit c8718a0

Please sign in to comment.