Skip to content

Commit

Permalink
Merge pull request #12213 from rabbitmq/mergify/bp/v4.0.x/pr-12198
Browse files Browse the repository at this point in the history
Move selenium to root (backport #12198)
  • Loading branch information
MarcialRosales authored Sep 4, 2024
2 parents 2206d44 + 8650e79 commit 268804c
Show file tree
Hide file tree
Showing 266 changed files with 360 additions and 78 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/test-authnz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- erlang_version: "26.2"
elixir_version: 1.15.7
env:
SELENIUM_DIR: deps/rabbitmq_management/selenium
SELENIUM_DIR: selenium
DOCKER_NETWORK: rabbitmq_net
steps:
- name: Checkout
Expand Down Expand Up @@ -91,7 +91,8 @@ jobs:
- name: Run Suites
run: |
RABBITMQ_DOCKER_IMAGE=bazel/packaging/docker-image:rabbitmq-amd64 ${SELENIUM_DIR}/run-suites.sh full-suite-authnz-messaging
RABBITMQ_DOCKER_IMAGE=bazel/packaging/docker-image:rabbitmq-amd64 \
${SELENIUM_DIR}/run-suites.sh full-suite-authnz-messaging
- name: Upload Test Artifacts
if: always()
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/test-management-ui-for-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Test Management UI with Selenium for PRs
on:
pull_request:
paths:
- 'deps/**'
- 'selenium/**'
- .github/workflows/test-management-ui-for-pr.yaml
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
selenium:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
erlang_version:
- "26.2"
browser:
- chrome
include:
- erlang_version: "26.2"
elixir_version: 1.15.7
env:
SELENIUM_DIR: selenium
DOCKER_NETWORK: rabbitmq_net
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure OTP & Elixir
uses: erlef/[email protected]
with:
otp-version: ${{ matrix.erlang_version }}
elixir-version: ${{ matrix.elixir_version }}
hexpm-mirrors: |
https://builds.hex.pm
https://cdn.jsdelivr.net/hex
- name: Authenticate To Google Cloud
uses: google-github-actions/[email protected]
with:
credentials_json: ${{ secrets.REMOTE_CACHE_CREDENTIALS_JSON }}

- name: Configure Bazel
run: |
if [ -n "${{ secrets.REMOTE_CACHE_BUCKET_NAME }}" ]; then
cat << EOF >> user.bazelrc
build --remote_cache=https://storage.googleapis.com/${{ secrets.REMOTE_CACHE_BUCKET_NAME }}
build --google_default_credentials
build --remote_download_toplevel
EOF
fi
cat << EOF >> user.bazelrc
build --color=yes
EOF
- name: Build & Load RabbitMQ OCI
run: |
bazelisk run packaging/docker-image:rabbitmq-amd64
- name: Configure Docker Network
run: |
docker network create ${DOCKER_NETWORK}
- name: Build Test Runner Image
run: |
cd ${SELENIUM_DIR}
docker build -t mocha-test --target test .
- name: Run full ui suites on a standalone rabbitmq server
run: |
RABBITMQ_DOCKER_IMAGE=bazel/packaging/docker-image:rabbitmq-amd64 \
${SELENIUM_DIR}/run-suites.sh
mkdir -p /tmp/full-suite
mv /tmp/selenium/* /tmp/full-suite
mkdir -p /tmp/full-suite/logs
mv ${SELENIUM_DIR}/logs/* /tmp/full-suite/logs
mkdir -p /tmp/full-suite/screens
mv ${SELENIUM_DIR}/screens/* /tmp/full-suite/screens
- name: Upload Test Artifacts
if: always()
uses: actions/[email protected]
with:
name: test-artifacts-${{ matrix.browser }}-${{ matrix.erlang_version }}
path: |
/tmp/full-suite
summary-selenium:
needs:
- selenium
runs-on: ubuntu-latest
steps:
- name: SUMMARY
run: |
echo "SUCCESS"
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ on:
- BUILD.*
- '*.bzl'
- '*.bazel'
- .github/workflows/test-selenium.yaml
pull_request:
paths:
- 'deps/rabbitmq_management/**'
- .github/workflows/test-selenium-for-pull-requests.yaml
- 'selenium/**'
- .github/workflows/test-management-ui.yaml

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
Expand All @@ -38,7 +36,7 @@ jobs:
- erlang_version: "26.2"
elixir_version: 1.15.7
env:
SELENIUM_DIR: deps/rabbitmq_management/selenium
SELENIUM_DIR: selenium
DOCKER_NETWORK: rabbitmq_net
steps:
- name: Checkout
Expand Down Expand Up @@ -85,17 +83,6 @@ jobs:
cd ${SELENIUM_DIR}
docker build -t mocha-test --target test .
- name: Run full ui suites on a standalone rabbitmq server
run: |
RABBITMQ_DOCKER_IMAGE=bazel/packaging/docker-image:rabbitmq-amd64 \
${SELENIUM_DIR}/run-suites.sh
mkdir -p /tmp/full-suite
mv /tmp/selenium/* /tmp/full-suite
mkdir -p /tmp/full-suite/logs
mv ${SELENIUM_DIR}/logs/* /tmp/full-suite/logs
mkdir -p /tmp/full-suite/screens
mv ${SELENIUM_DIR}/screens/* /tmp/full-suite/screens
- name: Run short ui suite on a 3-node rabbitmq cluster
run: |
RABBITMQ_DOCKER_IMAGE=bazel/packaging/docker-image:rabbitmq-amd64 \
Expand All @@ -113,7 +100,6 @@ jobs:
with:
name: test-artifacts-${{ matrix.browser }}-${{ matrix.erlang_version }}
path: |
/tmp/full-suite
/tmp/short-suite
summary-selenium:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
{oauth2_pem_config2,
{root_resource_server,
"auth_oauth2.resource_server_id = new_resource_server_id
auth_oauth2.scope_prefix = new_resource_server_id.
auth_oauth2.resource_server_type = new_resource_server_type
Expand Down Expand Up @@ -51,7 +51,7 @@
]}
],[]
},
{oauth2_pem_config3,
{multiple_resource_servers,
"auth_oauth2.resource_server_id = new_resource_server_id
auth_oauth2.scope_prefix = new_resource_server_id.
auth_oauth2.resource_server_type = new_resource_server_type
Expand Down Expand Up @@ -92,7 +92,7 @@
],
<<"rabbitmq-customers">> => [
{additional_scopes_key, <<"roles">>},
{id, <<"rabbitmq-customers">>}
{id, <<"rabbitmq-customers">>}
]
}
},
Expand All @@ -117,7 +117,7 @@
]}
],[]
},
{oauth2_pem_config4,
{multiple_oauth_providers,
"auth_oauth2.resource_server_id = new_resource_server_id
auth_oauth2.scope_prefix = new_resource_server_id.
auth_oauth2.resource_server_type = new_resource_server_type
Expand Down Expand Up @@ -174,5 +174,15 @@
}
]}
],[]
},
{empty_scope_prefix,
"auth_oauth2.resource_server_id = new_resource_server_id
auth_oauth2.scope_prefix = '' ",
[
{rabbitmq_auth_backend_oauth2, [
{resource_server_id,<<"new_resource_server_id">>},
{scope_prefix,<<>>}
]}
],[]
}
].
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ groups() -> [
is_verify_aud_for_resource_one_returns_true,
is_verify_aud_for_resource_two_returns_false
]},
get_scope_prefix_for_resource_one_returns_default_scope_prefix,
{with_root_scope_prefix, [], [
get_scope_prefix_for_resource_one_returns_root_scope_prefix,
{with_empty_scope_prefix_for_resource_one, [], [
get_scope_prefix_for_resource_one_returns_empty_scope_prefix,
get_scope_prefix_for_resource_two_returns_root_scope_prefix
]}
]},
{with_jwks_url, [], [
get_oauth_provider_for_both_resources_should_return_root_oauth_provider,
{with_oauth_providers_A_with_jwks_uri, [], [
Expand Down Expand Up @@ -160,6 +168,7 @@ groups() -> [
get_default_preferred_username_claims,
get_preferred_username_claims,
get_scope_prefix,
get_empty_scope_prefix,
get_scope_prefix_when_not_defined,
get_resource_server_type,
get_resource_server_type_when_not_defined,
Expand Down Expand Up @@ -309,6 +318,16 @@ init_per_group(with_resource_server_id, Config) ->
application:set_env(rabbitmq_auth_backend_oauth2, resource_server_id, ?RABBITMQ),
Config;

init_per_group(with_root_scope_prefix, Config) ->
application:set_env(rabbitmq_auth_backend_oauth2, scope_prefix, <<"some-prefix:">>),
Config;
init_per_group(with_empty_scope_prefix_for_resource_one, Config) ->
ResourceServers = application:get_env(rabbitmq_auth_backend_oauth2, resource_servers, #{}),
Proplist = maps:get(?RABBITMQ_RESOURCE_ONE, ResourceServers, []),
application:set_env(rabbitmq_auth_backend_oauth2, resource_servers,
maps:put(?RABBITMQ_RESOURCE_ONE, [{scope_prefix, <<"">>} | proplists:delete(scope_prefix, Proplist)], ResourceServers)),
Config;

init_per_group(with_verify_aud_false, Config) ->
application:set_env(rabbitmq_auth_backend_oauth2, verify_aud, false),
Config;
Expand Down Expand Up @@ -405,7 +424,9 @@ end_per_group(with_root_static_signing_keys, Config) ->
KeyConfig = call_get_env(Config, key_config, []),
call_set_env(Config, key_config, KeyConfig),
Config;

end_per_group(get_empty_scope_prefix, Config) ->
application:unset_env(rabbitmq_auth_backend_oauth2, scope_prefix),
Config;
end_per_group(with_resource_server_id, Config) ->
application:unset_env(rabbitmq_auth_backend_oauth2, resource_server_id),
Config;
Expand All @@ -418,6 +439,13 @@ end_per_group(with_verify_aud_false_for_resource_two, Config) ->
application:set_env(rabbitmq_auth_backend_oauth2, resource_servers,
maps:put(?RABBITMQ_RESOURCE_TWO, proplists:delete(verify_aud, Proplist), ResourceServers)),
Config;
end_per_group(with_empty_scope_prefix_for_resource_one, Config) ->
ResourceServers = application:get_env(rabbitmq_auth_backend_oauth2, resource_servers, #{}),
Proplist = maps:get(?RABBITMQ_RESOURCE_ONE, ResourceServers, []),
application:set_env(rabbitmq_auth_backend_oauth2, resource_servers,
maps:put(?RABBITMQ_RESOURCE_ONE, proplists:delete(scope_prefix, Proplist), ResourceServers)),
Config;

end_per_group(with_default_key, Config) ->
KeyConfig = application:get_env(rabbitmq_auth_backend_oauth2, key_config, []),
application:set_env(rabbitmq_auth_backend_oauth2, key_config,
Expand Down Expand Up @@ -507,6 +535,10 @@ end_per_group(inheritance_group, Config) ->
application:unset_env(rabbitmq_auth_backend_oauth2, resource_servers),
Config;

end_per_group(with_root_scope_prefix, Config) ->
application:unset_env(rabbitmq_auth_backend_oauth2, scope_prefix),
Config;

end_per_group(_any, Config) ->
Config.

Expand All @@ -520,6 +552,9 @@ init_per_testcase(get_additional_scopes_key_when_not_defined, Config) ->
init_per_testcase(is_verify_aud_when_is_false, Config) ->
application:set_env(rabbitmq_auth_backend_oauth2, verify_aud, false),
Config;
init_per_testcase(get_empty_scope_prefix, Config) ->
application:set_env(rabbitmq_auth_backend_oauth2, scope_prefix, <<"">>),
Config;
init_per_testcase(get_scope_prefix_when_not_defined, Config) ->
application:unset_env(rabbitmq_auth_backend_oauth2, scope_prefix),
Config;
Expand Down Expand Up @@ -756,11 +791,35 @@ get_scope_prefix_when_not_defined(_Config) ->
?assertEqual(<<"rabbitmq.">>, rabbit_oauth2_config:get_scope_prefix()),
?assertEqual(<<"rabbitmq2.">>, rabbit_oauth2_config:get_scope_prefix(<<"rabbitmq2">>)).

get_empty_scope_prefix(_Config) ->
?assertEqual(<<"">>, rabbit_oauth2_config:get_scope_prefix()),
?assertEqual(<<"">>, rabbit_oauth2_config:get_scope_prefix(<<"rabbitmq2">>)).

get_scope_prefix(_Config) ->
?assertEqual(<<"some-prefix-">>, rabbit_oauth2_config:get_scope_prefix()),
?assertEqual(<<"my-prefix:">>, rabbit_oauth2_config:get_scope_prefix(<<"rabbitmq1">>)),
?assertEqual(rabbit_oauth2_config:get_scope_prefix(), rabbit_oauth2_config:get_scope_prefix(<<"rabbitmq2">>)).

get_scope_prefix_for_resource_one_returns_default_scope_prefix(_Config) ->
?assertEqual(undefined, application:get_env(rabbitmq_auth_backend_oauth2, scope_prefix)),
?assertEqual(append_paths(?RABBITMQ_RESOURCE_ONE, <<".">>),
rabbit_oauth2_config:get_scope_prefix(?RABBITMQ_RESOURCE_ONE)).
get_scope_prefix_for_resource_one_returns_root_scope_prefix(_Config) ->
{ok, Prefix} = application:get_env(rabbitmq_auth_backend_oauth2, scope_prefix),
?assertEqual(rabbit_oauth2_config:get_scope_prefix(),
rabbit_oauth2_config:get_scope_prefix(?RABBITMQ_RESOURCE_ONE)),
?assertEqual(Prefix,
rabbit_oauth2_config:get_scope_prefix(?RABBITMQ_RESOURCE_ONE)).
get_scope_prefix_for_resource_one_returns_empty_scope_prefix(_Config) ->
?assertEqual(<<"">>,
rabbit_oauth2_config:get_scope_prefix(?RABBITMQ_RESOURCE_ONE)).
get_scope_prefix_for_resource_two_returns_root_scope_prefix(_Config) ->
{ok, Prefix} = application:get_env(rabbitmq_auth_backend_oauth2, scope_prefix),
?assertEqual(rabbit_oauth2_config:get_scope_prefix(),
rabbit_oauth2_config:get_scope_prefix(?RABBITMQ_RESOURCE_TWO)),
?assertEqual(Prefix,
rabbit_oauth2_config:get_scope_prefix(?RABBITMQ_RESOURCE_TWO)).

get_resource_server_type_when_not_defined(_Config) ->
?assertEqual(<<>>, rabbit_oauth2_config:get_resource_server_type()),
?assertEqual(<<>>, rabbit_oauth2_config:get_resource_server_type(<<"rabbitmq2">>)).
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbitmq_auth_backend_oauth2/test/unit_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ test_validate_payload_resource_server_id_mismatch(_) ->
rabbit_auth_backend_oauth2:validate_payload(?RESOURCE_SERVER_ID, EmptyAud, ?DEFAULT_SCOPE_PREFIX)).

test_validate_payload_with_scope_prefix(_) ->
Scenarios = [ { <<>>,
Scenarios = [ { <<"">>,
#{<<"aud">> => [?RESOURCE_SERVER_ID],
<<"scope">> => [<<"foo">>, <<"foo.bar">>, <<"foo.other.third">> ]},
[<<"foo">>, <<"foo.bar">>, <<"foo.other.third">> ]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion deps/rabbitmq_management/selenium/test/oauth/env.local

This file was deleted.

9 changes: 9 additions & 0 deletions selenium/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
package-lock.json
screens/*/*
logs
suites/logs/*
suites/screens/*
test/oauth/*/h2/*.trace.db
test/oauth/*/h2/*.lock.db
*/target/*
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ FROM atools/jdk-maven-node:mvn3-jdk11-node16 as base
WORKDIR /code

COPY package.json package.json
COPY run-amqp10-roundtriptest run-amqp10-roundtriptest

FROM base as test
RUN npm install
Expand Down
Loading

0 comments on commit 268804c

Please sign in to comment.