- describe "with a correct authorization header for an existing user" do
- test "it assigns the user", %{conn: conn} do
- opts = %{
- optional: true,
- fetcher: &fetch_user/1
- }
-
- header = basic_auth_enc("dude", "guy")
-
- conn =
- conn
- |> Plug.Session.call(Plug.Session.init(@session_opts))
- |> fetch_session
- |> put_req_header("authorization", header)
- |> AuthenticationPlug.call(opts)
-
- assert %{user: @user} == conn.assigns
- assert get_session(conn, :user_id) == @user.id
- assert conn.halted == false
- end
-
- test "it assigns legacy user", %{conn: conn} do
- opts = %{
- optional: true,
- fetcher: fn _ -> {:ok, @legacy} end,
- update_legacy_password: false
- }
-
- header = basic_auth_enc("dude", "password")
-
- conn =
- conn
- |> Plug.Session.call(Plug.Session.init(@session_opts))
- |> fetch_session
- |> put_req_header("authorization", header)
- |> AuthenticationPlug.call(opts)
-
- assert %{user: @legacy} == conn.assigns
- assert get_session(conn, :user_id) == @legacy.id
- assert conn.halted == false
- end
+ @tag :skip_on_mac
+ test "with a crypt hash, it updates to a pkbdf2 hash", %{conn: conn} do
+ user =
+ insert(:user,
+ password_hash:
+ "$6$9psBWV8gxkGOZWBz$PmfCycChoxeJ3GgGzwvhlgacb9mUoZ.KUXNCssekER4SJ7bOK53uXrHNb2e4i8yPFgSKyzaW9CcmrDXWIEMtD1"
+ )
+
+ conn =
+ conn
+ |> assign(:auth_user, user)
+ |> assign(:auth_credentials, %{password: "password"})
+ |> AuthenticationPlug.call(%{})
+
+ assert conn.assigns.user.id == conn.assigns.auth_user.id
+ assert PlugHelper.plug_skipped?(conn, OAuthScopesPlug)
+
+ user = User.get_by_id(user.id)
+ assert "$pbkdf2" <> _ = user.password_hash