Skip to content

Commit

Permalink
Update to OTP 27 (#348)
Browse files Browse the repository at this point in the history
* Update to OTP 27

* Fix CT tests
  • Loading branch information
maennchen authored Jun 12, 2024
1 parent 819cd3b commit 3b12c8a
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 30 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/part_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ jobs:
include:
- otp: "26.0"
unstable: false
- otp: "26.2"
- otp: "26.2.5"
unstable: false
- otp: "27.0"
unstable: false
- otp: "master"
unstable: true
Expand Down Expand Up @@ -133,7 +135,9 @@ jobs:
include:
- otp: "26.0"
unstable: false
- otp: "26.2"
- otp: "26.2.5"
unstable: false
- otp: "27.0"
unstable: false
- otp: "master"
unstable: true
Expand Down Expand Up @@ -171,20 +175,27 @@ jobs:
matrix:
include:
- elixir: "1.14.5"
otp: "26.2.5"
unstable: false
- elixir: "1.15.8"
otp: "26.2.5"
unstable: false
- elixir: "1.15.7"
- elixir: "1.16.3"
otp: "26.2.5"
unstable: false
- elixir: "1.16.0"
- elixir: "1.17.0"
otp: "27.0"
unstable: false
- elixir: "main"
otp: "${{ needs.detectToolVersions.outputs.otpVersion }}"
unstable: true

steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
id: setupBEAM
with:
otp-version: "${{ needs.detectToolVersions.outputs.otpVersion }}"
otp-version: "${{ matrix.otp }}"
rebar3-version: "${{ needs.detectToolVersions.outputs.rebarVersion }}"
elixir-version: "${{ matrix.elixir }}"
version-type: strict
Expand Down
6 changes: 3 additions & 3 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
erlang 26.2.1
rebar 3.22.1
elixir 1.16.0
erlang 27.0
rebar 3.23.0
elixir 1.17.0
6 changes: 3 additions & 3 deletions lib/oidcc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ defmodule Oidcc do
...> Oidcc.jwt_profile_token(
...> subject,
...> pid,
...> "client_id",
...> System.fetch_env!("CLIENT_ID"),
...> "client_secret",
...> jwk,
...> %{scope: ["urn:zitadel:iam:org:project:id:zitadel:aud"], kid: kid}
...> %{scope: ["openid", "urn:zitadel:iam:org:project:id:zitadel:aud"], kid: kid}
...> )
"""
Expand Down Expand Up @@ -331,7 +331,7 @@ defmodule Oidcc do
...> pid,
...> System.fetch_env!("CLIENT_CREDENTIALS_CLIENT_ID"),
...> System.fetch_env!("CLIENT_CREDENTIALS_CLIENT_SECRET"),
...> %{scope: ["scope"]}
...> %{scope: ["openid"]}
...> )
"""
Expand Down
6 changes: 3 additions & 3 deletions lib/oidcc/token.ex
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ defmodule Oidcc.Token do
...> {:ok, client_context} =
...> Oidcc.ClientContext.from_configuration_worker(
...> pid,
...> "client_id",
...> System.fetch_env!("CLIENT_ID"),
...> "client_secret"
...> )
...>
Expand All @@ -382,7 +382,7 @@ defmodule Oidcc.Token do
...> subject,
...> client_context,
...> jwk,
...> %{scope: ["urn:zitadel:iam:org:project:id:zitadel:aud"], kid: kid}
...> %{scope: ["openid", "urn:zitadel:iam:org:project:id:zitadel:aud"], kid: kid}
...> )
"""
Expand Down Expand Up @@ -427,7 +427,7 @@ defmodule Oidcc.Token do
...> {:ok, %Oidcc.Token{}} =
...> Oidcc.Token.client_credentials(
...> client_context,
...> %{scope: ["scope"]}
...> %{scope: ["openid"]}
...> )
"""
Expand Down
3 changes: 2 additions & 1 deletion priv/test/fixtures/zitadel-client-credentials.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"clientId": "Client Credential Test",
"clientSecret": "wb3poHlNp6fEvcspSnAwnfnkUET0LxbafbsL3kftJuVybcJkHRomGNNgcX3Hl3yf"
"clientSecret": "wb3poHlNp6fEvcspSnAwnfnkUET0LxbafbsL3kftJuVybcJkHRomGNNgcX3Hl3yf",
"project": "231391584430604723"
}
6 changes: 6 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
{jose, "~> 1.11"}
]}.

%% TODO: Remove once the following issue is resolved:
%% https://github.com/potatosalad/erlang-jose/issues/168
{overrides, [
{override, jose, [{erl_opts, []}]}
]}.

{project_plugins, [
%% Revert back to released version when this PR is merged & released:
%% https://github.com/markusn/coveralls-erl/pull/36
Expand Down
11 changes: 7 additions & 4 deletions test/oidcc/token_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ defmodule Oidcc.TokenTest do

%{
"clientId" => client_credentials_client_id,
"clientSecret" => client_credentials_client_secret
"clientSecret" => client_credentials_client_secret,
"project" => project
} =
:oidcc
|> Application.app_dir("priv/test/fixtures/zitadel-client-credentials.json")
Expand All @@ -30,6 +31,7 @@ defmodule Oidcc.TokenTest do

@client_credentials_client_id client_credentials_client_id
@client_credentials_client_secret client_credentials_client_secret
@project project

@jwt_profile :oidcc
|> Application.app_dir("priv/test/fixtures/zitadel-jwt-profile.json")
Expand All @@ -39,6 +41,7 @@ defmodule Oidcc.TokenTest do

setup_all do
# Used in doctests
System.put_env("CLIENT_ID", @project)
System.put_env("CLIENT_CREDENTIALS_CLIENT_ID", @client_credentials_client_id)
System.put_env("CLIENT_CREDENTIALS_CLIENT_SECRET", @client_credentials_client_secret)
System.put_env("JWT_PROFILE", @jwt_profile)
Expand Down Expand Up @@ -185,7 +188,7 @@ defmodule Oidcc.TokenTest do
{:ok, client_context} =
ClientContext.from_configuration_worker(
pid,
"client_id",
@project,
"client_secret"
)

Expand All @@ -198,7 +201,7 @@ defmodule Oidcc.TokenTest do
subject,
client_context,
jwk,
%{scope: ["urn:zitadel:iam:org:project:id:zitadel:aud"], kid: kid}
%{scope: ["openid", "urn:zitadel:iam:org:project:id:zitadel:aud"], kid: kid}
)
end
end
Expand All @@ -220,7 +223,7 @@ defmodule Oidcc.TokenTest do
assert {:ok, %Token{}} =
Oidcc.Token.client_credentials(
client_context,
%{scope: ["scope"]}
%{scope: ["openid"]}
)
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/oidcc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ retrieve_jwt_profile_token(_Config) ->
oidcc:jwt_profile_token(
<<"231391584430604723">>,
ZitadelConfigurationPid,
<<"client_id">>,
<<"231391584430604723">>,
<<"client_secret">>,
Key,
#{
scope => [<<"urn:zitadel:iam:org:project:id:zitadel:aud">>],
scope => [<<"openid">>, <<"urn:zitadel:iam:org:project:id:zitadel:aud">>],
kid => maps:get(<<"keyId">>, KeyMap)
}
)
Expand Down
5 changes: 3 additions & 2 deletions test/oidcc_http_util_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

all() ->
[
bad_ssl,
client_cert
bad_ssl
%% Disable because of 403
% client_cert
].

init_per_suite(_Config) ->
Expand Down
11 changes: 7 additions & 4 deletions test/oidcc_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ defmodule OidccTest do

%{
"clientId" => client_credentials_client_id,
"clientSecret" => client_credentials_client_secret
"clientSecret" => client_credentials_client_secret,
"project" => project
} =
:oidcc
|> Application.app_dir("priv/test/fixtures/zitadel-client-credentials.json")
Expand All @@ -17,6 +18,7 @@ defmodule OidccTest do

@client_credentials_client_id client_credentials_client_id
@client_credentials_client_secret client_credentials_client_secret
@project project

@jwt_profile :oidcc
|> Application.app_dir("priv/test/fixtures/zitadel-jwt-profile.json")
Expand All @@ -26,6 +28,7 @@ defmodule OidccTest do

setup_all do
# Used in doctests
System.put_env("CLIENT_ID", @project)
System.put_env("CLIENT_CREDENTIALS_CLIENT_ID", @client_credentials_client_id)
System.put_env("CLIENT_CREDENTIALS_CLIENT_SECRET", @client_credentials_client_secret)
System.put_env("JWT_PROFILE", @jwt_profile)
Expand Down Expand Up @@ -159,10 +162,10 @@ defmodule OidccTest do
Oidcc.jwt_profile_token(
subject,
pid,
"client_id",
@project,
"client_secret",
jwk,
%{scope: ["urn:zitadel:iam:org:project:id:zitadel:aud"], kid: kid}
%{scope: ["openid", "urn:zitadel:iam:org:project:id:zitadel:aud"], kid: kid}
)
end
end
Expand All @@ -179,7 +182,7 @@ defmodule OidccTest do
pid,
@client_credentials_client_id,
@client_credentials_client_secret,
%{scope: ["scope"]}
%{scope: ["openid"]}
)
end
end
Expand Down
6 changes: 3 additions & 3 deletions test/oidcc_token_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ retrieves_jwt_profile_token(_Config) ->

{ok, SalesforceClientContext} = oidcc_client_context:from_configuration_worker(
SalesforceConfigurationPid,
<<"client_id">>,
<<"231391584430604723">>,
<<"client_secret">>
),

{ok, ZitadelClientContext} = oidcc_client_context:from_configuration_worker(
ZitadelConfigurationPid,
<<"client_id">>,
<<"231391584430604723">>,
<<"client_secret">>
),

Expand All @@ -53,7 +53,7 @@ retrieves_jwt_profile_token(_Config) ->
?assertMatch(
{ok, #oidcc_token{}},
oidcc_token:jwt_profile(<<"231391584430604723">>, ZitadelClientContext, Key, #{
scope => [<<"urn:zitadel:iam:org:project:id:zitadel:aud">>],
scope => [<<"openid">>, <<"urn:zitadel:iam:org:project:id:zitadel:aud">>],
kid => maps:get(<<"keyId">>, KeyMap)
})
),
Expand Down

0 comments on commit 3b12c8a

Please sign in to comment.