81578f6e27
Delegates all credential management (login, register, password reset, email verification, social sign-in) to Ory Kratos. The Go API now acts as a resource server: the new KratosAuth middleware validates sessions against the Kratos whoami endpoint, writes the local User mirror into Echo context, and all existing domain handlers continue working unchanged. Hand-rolled token auth, AuthToken model, apple_auth/ google_auth services, and the auth refresh flow are removed. Tests are updated to use the fake-token middleware pattern so existing integration assertions require no rewrite. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package models
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestUser_GetFullName(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
user User
|
|
expected string
|
|
}{
|
|
{
|
|
name: "first and last name",
|
|
user: User{FirstName: "John", LastName: "Doe", Username: "johndoe"},
|
|
expected: "John Doe",
|
|
},
|
|
{
|
|
name: "first name only",
|
|
user: User{FirstName: "John", LastName: "", Username: "johndoe"},
|
|
expected: "John",
|
|
},
|
|
{
|
|
name: "username fallback",
|
|
user: User{FirstName: "", LastName: "", Username: "johndoe"},
|
|
expected: "johndoe",
|
|
},
|
|
{
|
|
name: "last name only returns username",
|
|
user: User{FirstName: "", LastName: "Doe", Username: "johndoe"},
|
|
expected: "johndoe",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
result := tt.user.GetFullName()
|
|
assert.Equal(t, tt.expected, result)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestUser_TableName(t *testing.T) {
|
|
user := User{}
|
|
assert.Equal(t, "auth_user", user.TableName())
|
|
}
|
|
|
|
func TestUserProfile_TableName(t *testing.T) {
|
|
profile := UserProfile{}
|
|
assert.Equal(t, "user_userprofile", profile.TableName())
|
|
}
|