diff --git a/lib/ueberauth/strategy/steam.ex b/lib/ueberauth/strategy/steam.ex index 20e82ed..a3777ca 100644 --- a/lib/ueberauth/strategy/steam.ex +++ b/lib/ueberauth/strategy/steam.ex @@ -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, } diff --git a/test/ueberauth/strategy/steam_test.exs b/test/ueberauth/strategy/steam_test.exs index 75e507c..a284f0a 100644 --- a/test/ueberauth/strategy/steam_test.exs +++ b/test/ueberauth/strategy/steam_test.exs @@ -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 @@ -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}}