Skip to content

Commit bf98a80

Browse files
authored
🐛 OAuth2 sign-in flow, profile auto-creation, and E2E tests (#10)
## Summary - OAuth2ログインフロー(Ory Hydra + Kratos)の修正と安定化 - Account作成時にProfileを自動生成する機能を追加 - axum 0.8 / tower-http 0.6 へのアップグレード - Keto OPL (Ory Permission Language) への権限モデル移行 - OpenAPIスペック駆動のスモークテスト追加 - OAuth2ログイン→Account作成→Profile自動生成を検証するE2Eテスト追加 (`server/tests/e2e_basic_flow.rs`) ## Changes ### Bug Fixes - `:bug:` HTTP 302 を OAuth2 login/consent エンドポイントから正しく返すように修正 - `:bug:` OffsetDateTime を ISO 8601 (RFC3339) フォーマットにシリアライズするよう修正 - `:bug:` CommandProcessor で Account ReadModel 作成を同期化し、`find_or_create` パターンの競合を防止 - `:bug:` Keto v0.12 の HTTP 403 レスポンス処理を修正 ### Features - `:sparkles:` Account 作成時に Profile を自動生成 - `:sparkles:` Hydra id_token に email クレームを含める ### Refactoring - `:recycle:` Keto 権限モデルを OPL に移行 - `:recycle:` パスパラメータ名を OpenAPI 一貫性のために統一 - `:recycle:` ルートスモークテストを OpenAPI スペック駆動に変更 - `:arrow_up:` axum 0.8, tower-http 0.6 へアップグレード ### Testing - `:white_check_mark:` E2E テスト追加: OAuth2 login → Account 作成 → Profile 非同期プロジェクション検証 - `justfile` に `just e2e` / `just e2e-down` コマンド追加 - reqwest によるブラックボックス HTTP テスト - Ory Hydra/Kratos との完全な OAuth2 フロー実行 ## Running E2E Tests ```bash # 必要サービスの起動を含め全自動で実行 just e2e # サービスの後片付け just e2e-down ```
2 parents 82e3a65 + b22a4a5 commit bf98a80

33 files changed

Lines changed: 1489 additions & 657 deletions

File tree

.github/workflows/e2e.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches: [main, fix/signin]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
e2e:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 30
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Rust toolchain
19+
uses: dtolnay/rust-toolchain@stable
20+
21+
- name: Cache Rust build artifacts
22+
uses: Swatinem/rust-cache@v2
23+
24+
- name: Install just
25+
uses: extractions/setup-just@v2
26+
27+
- name: Install cargo-binstall
28+
uses: cargo-bins/cargo-binstall@main
29+
30+
- name: Install sqlx-cli
31+
run: cargo binstall sqlx-cli --no-confirm
32+
33+
- name: Create master-key-password file
34+
run: |
35+
echo -n "ci-test-master-key-password" > master-key-password
36+
chmod 600 master-key-password
37+
38+
- name: Create .env file
39+
run: |
40+
{
41+
echo "DATABASE_URL=postgres://postgres:develop@localhost:5432/postgres"
42+
echo "HYDRA_ISSUER_URL=http://localhost:4444/"
43+
echo "HYDRA_ADMIN_URL=http://localhost:4445/"
44+
echo "KRATOS_PUBLIC_URL=http://localhost:4433/"
45+
echo "EXPECTED_AUDIENCE=account"
46+
echo "KETO_READ_URL=http://localhost:4466"
47+
echo "KETO_WRITE_URL=http://localhost:4467"
48+
echo "REDIS_URL=redis://localhost:6379"
49+
echo "WORKER_ID=0"
50+
echo "CORS_ALLOWED_ORIGINS=*"
51+
} > .env
52+
53+
- name: Run E2E tests
54+
run: just e2e
55+
56+
- name: Collect docker logs on failure
57+
if: failure()
58+
run: docker compose logs
59+
60+
- name: Stop services
61+
if: always()
62+
run: just down

CLAUDE.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
66

77
Emumet is an Account Service for ShuttlePub, implementing Event Sourcing with CQRS pattern. The name derives from EMU (Extravehicular Mobility Unit) + Helmet.
88

9+
## Git Commit Convention
10+
11+
コミットメッセージには [gitmoji](https://gitmoji.dev/) をプレフィックスとして付けること。
12+
13+
形式: `:gitmoji: Subject line`
14+
15+
例:
16+
- `:sparkles: Add user registration endpoint` (新機能)
17+
- `:bug: Fix race condition in event store` (バグ修正)
18+
- `:recycle: Refactor DependOn trait hierarchy` (リファクタリング)
19+
- `:memo: Update API spec` (ドキュメント)
20+
- `:white_check_mark: Add integration tests for profile` (テスト)
21+
- `:zap: Optimize batch query for profiles` (パフォーマンス)
22+
- `:wrench: Update environment config` (設定)
23+
924
## Build & Development Commands
1025

1126
```bash
@@ -128,7 +143,7 @@ Query Flow:
128143

129144
**application** provides use case services and event appliers:
130145
- `GetAccountUseCase` / `CreateAccountUseCase` / `UpdateAccountUseCase` / `DeactivateAccountUseCase` / `SuspendAccountUseCase` / `UnsuspendAccountUseCase` / `BanAccountUseCase` — Account CRUD + moderation orchestration via CommandProcessor/QueryProcessor
131-
- `GetProfileUseCase` / `CreateProfileUseCase` / `UpdateProfileUseCase` — Profile CRUD
146+
- `GetProfileUseCase` / `UpdateProfileUseCase` — Profile read/update (Profile is auto-created during Account creation)
132147
- `GetMetadataUseCase` / `CreateMetadataUseCase` / `UpdateMetadataUseCase` / `DeleteMetadataUseCase` — Metadata CRUD
133148
- `UpdateAuthAccount` / `UpdateProfile` / `UpdateMetadata` — event appliers that replay events from EventStore, update ReadModel projections
134149

0 commit comments

Comments
 (0)