Skip to content

Conversation

begedin
Copy link
Contributor

@begedin begedin commented Sep 13, 2017

Closes #790

Makes use of the same FailureAPI mock module used in #805 and #925, so depending on merge order, there may be an easily resolvable conflict.

I did not add a test for the changeset case because it doesn't seem to be possible for it to happen, since the only validations are those for presence of github keys, and these cannot be nil.


assert json["data"]["id"] |> String.to_integer == user.id
test "requires authentication", %{conn: conn} do
path = user_path(conn, :github_oauth, %{"code" => "foo", "state" => "bar"})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm misreading this entirely, I think what's confusing me about this test is that it implies that valid_code and valid_state somehow work whereas foo and bar would not, when in reality it simply tests that the user is authenticated with our system regardless of the params that make it to GitHub.

Can you clarify @begedin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work regardless, I'll update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshsmith To clarify, the controller action was implemented with the code and state in the signature. I've moved attrs into a module variable, so it doesn't imply that specific values are important.

However, the action will only work with attributes containing code and state keys.

Not sure if I should loosen that requirement, or write a test for it. Either way, this PR is about closing #790. If we want to loosen the requirement, then that requires a rewrite of GitHub.User as well, so I would do it separately. Adding a test could go here, but this would be the first time we're writing a test for such a case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This addresses totally what I was taking issue with, thanks!

def request(method, url, headers, body, options) do
case {method, url} |> for_access_token?() do
true -> SuccessAPI.request(method, url, headers, body, options)
false ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there's a way to metaprogram this and use an @impl or something?

@begedin begedin force-pushed the 790-connect-action-error-handling branch from 3cf9fa6 to 2aabd9e Compare September 14, 2017 06:11
@joshsmith joshsmith force-pushed the 790-connect-action-error-handling branch from a90b6fc to ff4a4db Compare September 14, 2017 20:41
@joshsmith joshsmith merged commit 8253379 into develop Sep 14, 2017
@joshsmith joshsmith deleted the 790-connect-action-error-handling branch September 14, 2017 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants