-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from cheerfulstoic/freeze-httpoison-jason-issu…
…e-#45 Freeze httpoison jason issue #45
- Loading branch information
Showing
10 changed files
with
136 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,4 @@ _build | |
cover/ | ||
|
||
.vscode/ | ||
doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
defmodule ElixirAuthMicrosoft.HTTPoisonMock do | ||
def get("https://login.microsoftonline.com/common/oauth2/v2.0/authorize") do | ||
{:error, :bad_request} | ||
end | ||
@moduledoc """ | ||
SHOULD BE THE SAME AS THE ORIGINAL `httpoison_mock.ex`. | ||
""" | ||
@spec get(any, nonempty_maybe_improper_list) :: {:error, :bad_request} | {:ok, %{body: binary}} | ||
def get(_url, [ {:Authorization, token} = _authorization | _content_type]) do | ||
is_token_valid = token !== "Bearer invalid_token" | ||
|
||
def get(_url, _headers) do | ||
{:ok, | ||
%{ | ||
body: | ||
Jason.encode!(%{ | ||
businessPhones: [], | ||
displayName: "Test Name", | ||
givenName: "Test", | ||
id: "192jnsd9010apd", | ||
jobTitle: nil, | ||
mail: nil, | ||
mobilePhone: '+351928837834', | ||
officeLocation: nil, | ||
preferredLanguage: nil, | ||
surname: "Name", | ||
userPrincipalName: "[email protected]"} | ||
) | ||
}} | ||
if is_token_valid do | ||
{:ok, | ||
%{ | ||
body: | ||
Jason.encode!(%{ | ||
businessPhones: [], | ||
displayName: "Test Name", | ||
givenName: "Test", | ||
id: "192jnsd9010apd", | ||
jobTitle: nil, | ||
mail: nil, | ||
mobilePhone: '+351928837834', | ||
officeLocation: nil, | ||
preferredLanguage: nil, | ||
surname: "Name", | ||
userPrincipalName: "[email protected]"} | ||
) | ||
}} | ||
else | ||
{:error, :bad_request} | ||
end | ||
end | ||
|
||
|
||
@spec post(any, any, any) :: {:ok, %{body: binary}} | ||
def post(_url, _body, _headers) do | ||
{:ok, %{body: Jason.encode!(%{access_token: "token1", code: "code1"})}} | ||
{:ok, %{body: Jason.encode!(%{access_token: "token1"})}} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters