Skip to content

Commit

Permalink
Do not fail if could not verify auth key (hexpm#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmj authored Sep 30, 2021
1 parent 5aaaf52 commit a090037
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/mix/tasks/hex.organization.ex
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,12 @@ defmodule Mix.Tasks.Hex.Organization do
{:ok, {code, _body, _}} when code in 200..299 ->
:ok

{:ok, {code, _body, _}} when code in [401, 403] ->
Hex.Shell.error("Failed to authenticate against organization repository with given key")

other ->
Hex.Utils.print_error_result(other)
Mix.raise("Failed to authenticate against organization repository with given key")
Hex.Shell.error("Failed to verify authentication key")
end
end
end
7 changes: 3 additions & 4 deletions test/mix/tasks/hex.organization_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,10 @@ defmodule Mix.Tasks.Hex.OrganizationTest do
test "auth --key with invalid key" do
in_tmp(fn ->
set_home_cwd()
message = "Failed to authenticate against organization repository with given key"
Mix.Tasks.Hex.Organization.run(["auth", "myorg", "--key", "mykey"])

assert_raise Mix.Error, message, fn ->
Mix.Tasks.Hex.Organization.run(["auth", "myorg", "--key", "mykey"])
end
assert_received {:mix_shell, :error,
["Failed to authenticate against organization repository with given key"]}
end)
end

Expand Down

0 comments on commit a090037

Please sign in to comment.