refactor: structure of an hexagonal architecture
Created a kernel crate to store models and future action implementations. Will be useful to create admin cli.
This commit is contained in:
parent
69af48bb62
commit
3713cc2443
87 changed files with 834 additions and 474 deletions
56
tests/hurl_integration/scenario_1/config.toml
Normal file
56
tests/hurl_integration/scenario_1/config.toml
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
[instance]
|
||||
base_uri = "http://localhost:8086"
|
||||
name = "Example org"
|
||||
logo_uri = "https://example.org/logo.png"
|
||||
|
||||
[[applications]]
|
||||
slug = "demo_app"
|
||||
name = "Demo app"
|
||||
description = "A super application where you can do everything you want."
|
||||
client_id = "00000001-0000-0000-0000-000000000001"
|
||||
client_secret = "dummy_client_secret"
|
||||
login_uri = "https://localhost:9876"
|
||||
allowed_redirect_uris = [
|
||||
"http://localhost:9090/callback",
|
||||
"http://localhost:9876/callback"
|
||||
]
|
||||
visibility = "Internal"
|
||||
authorize_flow = "Implicit"
|
||||
|
||||
[[applications]]
|
||||
slug = "wiki"
|
||||
name = "Wiki app"
|
||||
description = "The knowledge base of the exemple org."
|
||||
client_id = "f9de1885-448d-44bb-8c48-7e985486a8c6"
|
||||
client_secret = "49c6c16a-0a8a-4981-a60d-5cb96582cc1a"
|
||||
login_uri = "https://wiki.example.org/login"
|
||||
allowed_redirect_uris = [
|
||||
"https://wiki.example.org/oauth2/callback"
|
||||
]
|
||||
visibility = "Public"
|
||||
authorize_flow = "Implicit"
|
||||
|
||||
[[applications]]
|
||||
slug = "private_app"
|
||||
name = "Demo app"
|
||||
description = "Private app you should never discover"
|
||||
client_id = "c8a08783-2342-4ce3-a3cb-9dc89b6bdf"
|
||||
client_secret = "this_is_the_secret"
|
||||
login_uri = "https://private-app.org"
|
||||
allowed_redirect_uris = [
|
||||
"http://localhost:9091/authorize",
|
||||
]
|
||||
visibility = "Private"
|
||||
authorize_flow = "Implicit"
|
||||
|
||||
[[roles]]
|
||||
slug = "basic"
|
||||
name = "Basic"
|
||||
description = "Basic user"
|
||||
default = true
|
||||
|
||||
[[roles]]
|
||||
slug = "admin"
|
||||
name = "Administrator"
|
||||
description = "Full power on organization instance"
|
||||
|
||||
9
tests/hurl_integration/scenario_1/init_db.sh
Executable file
9
tests/hurl_integration/scenario_1/init_db.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
password_hash="$(echo -n "root" | argon2 salt_06cGGWYDJCZ -e)"
|
||||
echo $password_hash
|
||||
SQL=$(cat <<EOF
|
||||
INSERT INTO users
|
||||
(id, handle, email, roles, status, password_hash, created_at)
|
||||
VALUES
|
||||
('$(uuid)', 'root', 'root@example.org', '[]', 'Active', '$password_hash', '2024-11-30T00:00:00Z');
|
||||
EOF)
|
||||
echo $SQL | sqlite3 $DB_PATH
|
||||
BIN
tests/hurl_integration/scenario_1/john_doe_profile_pic.jpg
Normal file
BIN
tests/hurl_integration/scenario_1/john_doe_profile_pic.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
88
tests/hurl_integration/scenario_1/main.hurl
Normal file
88
tests/hurl_integration/scenario_1/main.hurl
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
GET {{ base_url }}/api
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.software" == "Minauthator"
|
||||
|
||||
POST {{ base_url }}/login
|
||||
[FormParams]
|
||||
login: root
|
||||
password: root
|
||||
HTTP 303
|
||||
[Captures]
|
||||
user_jwt: cookie "minauthator_jwt"
|
||||
[Asserts]
|
||||
cookie "minauthator_jwt" exists
|
||||
cookie "minauthator_jwt[Value]" contains "eyJ0"
|
||||
cookie "minauthator_jwt[SameSite]" == "Lax"
|
||||
|
||||
GET {{ base_url }}/me
|
||||
HTTP 200
|
||||
Content-Type: text/html; charset=utf-8
|
||||
[Asserts]
|
||||
xpath "string(///h1)" == "Welcome root!"
|
||||
|
||||
POST {{ base_url }}/me/details-form
|
||||
[MultipartFormData]
|
||||
handle: root
|
||||
email: root@johndoe.net
|
||||
full_name: John Doe
|
||||
website: https://johndoe.net
|
||||
picture: file,john_doe_profile_pic.jpg; image/jpeg
|
||||
HTTP 200
|
||||
|
||||
GET {{ base_url }}/me/authorizations
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
xpath "string(///h1)" == "Your authorizations"
|
||||
xpath "string(///i)" == "You didn't authorized or accessed any applications for now."
|
||||
|
||||
# OAuth2 implicit flow (pre-granted app)
|
||||
GET {{ base_url }}/authorize
|
||||
[QueryStringParams]
|
||||
client_id: 00000001-0000-0000-0000-000000000001
|
||||
response_type: code
|
||||
redirect_uri: http://localhost:9090/callback
|
||||
state: Afk4kf6pbZkms78jM
|
||||
scope: user_read_basic
|
||||
HTTP 302
|
||||
[Asserts]
|
||||
header "Location" contains "http://localhost:9090/callback?code="
|
||||
[Captures]
|
||||
authorization_code: header "Location" regex "\\?code=(.*)&"
|
||||
|
||||
# OAuth2 get access token
|
||||
POST {{ base_url }}/api/token
|
||||
[BasicAuth]
|
||||
00000001-0000-0000-0000-000000000001: dummy_client_secret
|
||||
[FormParams]
|
||||
code: {{ authorization_code }}
|
||||
scope: user_read_basic
|
||||
redirect_uri: http://localhost:9090/callback
|
||||
grant_type: authorization_code
|
||||
HTTP 200
|
||||
Content-Type: application/json
|
||||
[Asserts]
|
||||
jsonpath "$.access_token" exists
|
||||
jsonpath "$.access_token" matches "eyJ[[:alpha:]0-9].[[:alpha:]0-9].[[:alpha:]0-9]"
|
||||
[Captures]
|
||||
access_token: jsonpath "$.access_token"
|
||||
|
||||
# Get basic user info
|
||||
GET {{ base_url }}/api/user
|
||||
Authorization: JWT {{ access_token }}
|
||||
HTTP 200
|
||||
Content-Type: application/json
|
||||
[Asserts]
|
||||
jsonpath "$.handle" == "root"
|
||||
jsonpath "$.email" == "root@johndoe.net"
|
||||
|
||||
GET {{ base_url }}/me/authorizations
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
xpath "string(///h1)" == "Your authorizations"
|
||||
xpath "string(///main/ul/li)" contains "UserReadBasic"
|
||||
|
||||
GET {{ base_url }}/logout
|
||||
HTTP 303
|
||||
[Asserts]
|
||||
cookie "minauthator_jwt" == ""
|
||||
Loading…
Add table
Add a link
Reference in a new issue