Тестирование
Тестирование
Настройка Auth0
- Регистрируемся на Auth0.
- Создаем приложение:
Applications
->Create Application
:Native
, заходим в созданное приложение и копируемClient ID
иClient Secret
. - Переходим в
Advanced Settings
->Grant Types
: толькоPassword
(Resource Owner Password Flow). - Переходим в
API
->Create API
:- Name:
Cinema Aggregator Service
; - Identifier:
http://store.romanow-alex.ru
; - Signing Algorithm: RS256.
- Name:
- Настраиваем хранилище паролей:
Settings
->Tenant Settings
->API Authorization Settings
:- Default Audience:
http://store.romanow-alex.ru
; - Default Directory:
Username-Password-Authentication
.
- Default Audience:
- Создаем тестового пользователя:
User Management
->Users
->Create User
:- Email:
ronin@romanow-alex.ru
; - Password:
Qwerty123
; - Connection:
Username-Password-Authentication
.
- Email:
После настройки у вас должен успешно выполняться запрос на проверку получение токена (подставить свои настройки):
$ curl --location --request POST 'https://romanowalex.eu.auth0.com/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=ronin@romanow-alex.ru' \
--data-urlencode 'password=Qwerty123' \
--data-urlencode 'scope=openid' \
--data-urlencode 'client_id=<Client ID>' \
--data-urlencode 'client_secret=<Client Secret>'
В ответ получаем токен:
{
"access_token": "...",
"id_token": "...",
"scope": "openid profile email ...",
"expires_in": 86400,
"token_type": "Bearer"
}
Нагрузочное тестирование
$ brew install k6
$ export SPRING_PROFILES_ACTIVE=docker,auth0
$ export OAUTH2_SECURITY_ENABLED=true
$ export TRACING_ENABLED=true
$ docker compose \
-f docker-compose.yml \
-f docker-compose.tracing.yml \
-f docker-compose.influxdb.yml \
-f docker-compose.monitoring.yml \
up -d --wait
# можно использовать встроенные dashboards: K6_WEB_DASHBOARD=true K6_WEB_DASHBOARD_EXPORT=report.html
# – Auth0: https://romanowalex.eu.auth0.com/oauth/token
# – Keycloak: http://keycloak:8100/realms/master/protocol/openid-connect/token
$ k6 run \
--out influxdb=http://localhost:8086/k6 \
-e IDENTITY_PROVIDER=https://romanowalex.eu.auth0.com/oauth/token \
-e USERNAME=ronin@romanow-alex.ru \
-e PASSWORD=Qwerty123 \
-e CLIENT_ID=<Client ID> \
-e CLIENT_SECRET=<Client Secret> \
k6-load.js