refactor(api): enforce protocol-neutral service boundaries
- refactor: move HTTP status and DTO concerns out of model and service layers into API and handler code. - feat: add admin service boundary and route auth through services instead of direct repository access. - test: add architecture and error tests covering package boundaries, redaction, and service behavior. - docs: record the protocol-neutral boundary decision and update architecture and roadmap notes.
This commit is contained in:
@@ -17,6 +17,11 @@ import (
|
||||
"github.com/dhao2001/mygo/internal/service"
|
||||
)
|
||||
|
||||
type testTokenPairResponse struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
}
|
||||
|
||||
func setupTestAuthService(t *testing.T) (*service.AuthService, []byte) {
|
||||
t.Helper()
|
||||
|
||||
@@ -140,7 +145,7 @@ func TestLoginHandler(t *testing.T) {
|
||||
t.Errorf("status = %d, want %d; body = %s", rec.Code, http.StatusOK, rec.Body.String())
|
||||
}
|
||||
|
||||
var pair service.TokenPair
|
||||
var pair testTokenPairResponse
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &pair); err != nil {
|
||||
t.Fatalf("unmarshal response: %v", err)
|
||||
}
|
||||
@@ -196,7 +201,7 @@ func TestRefreshHandler(t *testing.T) {
|
||||
rec = httptest.NewRecorder()
|
||||
r.ServeHTTP(rec, req)
|
||||
|
||||
var pair service.TokenPair
|
||||
var pair testTokenPairResponse
|
||||
json.Unmarshal(rec.Body.Bytes(), &pair)
|
||||
|
||||
// Refresh
|
||||
|
||||
Reference in New Issue
Block a user