Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix info for optional fields #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/ueberauth/strategy/steam.ex
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ defmodule Ueberauth.Strategy.Steam do

%Info{
image: user.avatar,
name: user.realname,
location: user.loccountrycode,
name: get_in(user, [:realname]),
location: get_in(user, [:loccountrycode]),
urls: %{
Steam: user.profileurl,
}
Expand Down
17 changes: 17 additions & 0 deletions test/ueberauth/strategy/steam_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ defmodule Ueberauth.Strategy.SteamTest do
realname: "Sample Sample", steamid: "765309403423",
timecreated: 452342342}
@sample_response %{response: %{players: [@sample_user]}}
@optional_fields [:loccountrycode, :realname]

describe "handle_request!" do
test "redirects" do
Expand Down Expand Up @@ -174,6 +175,22 @@ defmodule Ueberauth.Strategy.SteamTest do
end
end

describe "info retrievers fetch (nil optional fields)" do
setup do
conn = %{conn(:get, "http://example.com/path/callback") | private: %{steam_user: Map.drop(@sample_user, @optional_fields)}}
conn = Steam.handle_callback! conn

[conn: conn]
end

test "info", %{conn: conn} do
auth_info = %Ueberauth.Auth.Info{
image: "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f3/f3dsf34324eawdasdas3rwe.jpg",
urls: %{Steam: "http://steamcommunity.com/id/sample/"}}
assert Steam.info(conn) == auth_info
end
end

test "connection is cleaned up" do
conn = %{conn(:get, "http://example.com/path/callback") | private: %{steam_user: @sample_user}}

Expand Down