-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
383 additions
and
347 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,21 +11,21 @@ defmodule Codebattle.Auth.GithubMock do | |
`get/3` stubs the Req get! function when parameters match test vars. | ||
""" | ||
@valid_body %{ | ||
access_token: "12345", | ||
login: "test_user", | ||
name: "Testy McTestface", | ||
email: "[email protected]", | ||
avatar_url: "https://avatars3.githubusercontent.com/u/10835816", | ||
id: "19" | ||
"access_token" => "12345", | ||
"login" => "test_user", | ||
"name" => "Testy McTestface", | ||
"email" => "[email protected]", | ||
"avatar_url" => "https://avatars3.githubusercontent.com/u/10835816", | ||
"id" => "19" | ||
} | ||
|
||
@body_email_nil %{ | ||
access_token: "12345", | ||
login: "test_user", | ||
name: "Testy McTestface", | ||
email: nil, | ||
avatar_url: "https://avatars3.githubusercontent.com/u/10835816", | ||
id: "28" | ||
"access_token" => "12345", | ||
"login" => "test_user", | ||
"name" => "Testy McTestface", | ||
"email" => nil, | ||
"avatar_url" => "https://avatars3.githubusercontent.com/u/10835816", | ||
"id" => "28" | ||
} | ||
|
||
@emails [ | ||
|
@@ -64,7 +64,7 @@ defmodule Codebattle.Auth.GithubMock do | |
], | ||
_options | ||
) do | ||
%{body: Jason.encode!(@body_email_nil)} | ||
%{body: @body_email_nil} | ||
end | ||
|
||
# user emails | ||
|
@@ -76,46 +76,18 @@ defmodule Codebattle.Auth.GithubMock do | |
], | ||
_options | ||
) do | ||
%{body: Jason.encode!(@emails)} | ||
%{body: @emails} | ||
end | ||
|
||
def get!(_url, _headers, _options) do | ||
%{body: Jason.encode!(@valid_body)} | ||
%{body: @valid_body} | ||
end | ||
|
||
@doc """ | ||
`post/3` stubs the Req post! function when parameters match test vars. | ||
""" | ||
def post!(url, body, headers \\ [], options \\ []) | ||
|
||
def post!( | ||
"https://github.com/login/oauth/access_token?client_id=TEST_ID&client_secret=TEST_SECRET&code=1234", | ||
_body, | ||
_headers, | ||
_options | ||
) do | ||
%{body: "error=error"} | ||
end | ||
|
||
def post!( | ||
"https://github.com/login/oauth/access_token?client_id=TEST_ID&client_secret=TEST_SECRET&code=123", | ||
_body, | ||
_headers, | ||
_options | ||
) do | ||
%{body: "access_token=123"} | ||
end | ||
|
||
def post!( | ||
"https://github.com/login/oauth/access_token?client_id=TEST_ID&client_secret=TEST_SECRET&code=42", | ||
_body, | ||
_headers, | ||
_options | ||
) do | ||
%{body: "access_token=42"} | ||
end | ||
|
||
# for some reason GitHub's Post returns a URI encoded string | ||
def post!(_url, _body, _headers, _options) do | ||
%{body: URI.encode_query(@valid_body)} | ||
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
Oops, something went wrong.