Skip to content

Commit

Permalink
remove test and make dialyzer happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanspagh committed Mar 8, 2023
1 parent f7d672d commit 1155d12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 30 deletions.
14 changes: 8 additions & 6 deletions lib/k8s/conn/auth/azure.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ defmodule K8s.Conn.Auth.Azure do
@moduledoc """
`auth-provider` for azure
"""
alias K8s.Conn.Error
alias K8s.Conn.RequestOptions

require Logger
Expand Down Expand Up @@ -54,7 +53,7 @@ defmodule K8s.Conn.Auth.Azure do
end

@spec refresh_token(String.t(), String.t(), String.t(), String.t()) :: String.t()
defp refresh_token(tenant, refresh_token, client_id, _apiserver_id) do
def refresh_token(tenant, refresh_token, client_id, _apiserver_id) do
payload =
URI.encode_query(%{
"client_id" => client_id,
Expand All @@ -67,13 +66,16 @@ defmodule K8s.Conn.Auth.Azure do
:post,
URI.new!("https://login.microsoftonline.com/#{tenant}/oauth2/v2.0/token"),
payload,
%{
"Content-Type" => "application/x-www-form-urlencoded"
},
[
{
"Content-Type",
"application/x-www-form-urlencoded"
}
],
ssl: []
)

res["access_token"]
Map.get(res, "access_token")
end

defimpl RequestOptions, for: __MODULE__ do
Expand Down
24 changes: 0 additions & 24 deletions test/k8s/conn/auth/azure_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,6 @@ defmodule K8s.Conn.Auth.AzureTest do
token: "xxx"
}} = Azure.create(auth, nil)
end

@tag :skip
test "fails when token is expired" do
expired_unix_ts = DateTime.utc_now() |> DateTime.add(-10, :minute) |> DateTime.to_unix()

auth = %{
"auth-provider" => %{
"config" => %{
"access-token" => "xxx",
"apiserver-id" => "service_id",
"client-id" => "client_id",
"expires-on" => "#{expired_unix_ts}",
"refresh-token" => "yyy",
"tenant-id" => "tenant"
},
"name" => "azure"
}
}

assert {:error,
%K8s.Conn.Error{
message: "Azure token expired please refresh manually"
}} = Azure.create(auth, nil)
end
end

test "creates http request signing options" do
Expand Down

0 comments on commit 1155d12

Please sign in to comment.