26 lines
741 B
Go
26 lines
741 B
Go
|
|
package middleware
|
||
|
|
|
||
|
|
import (
|
||
|
|
"net/http"
|
||
|
|
"testing"
|
||
|
|
|
||
|
|
"haixun-backend/internal/model/member/domain/entity"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestEmailVerificationBypassed(t *testing.T) {
|
||
|
|
if !emailVerificationBypassed(http.MethodPost, "/api/v1/auth/verify-email") {
|
||
|
|
t.Fatal("verify-email should bypass")
|
||
|
|
}
|
||
|
|
if emailVerificationBypassed(http.MethodGet, "/api/v1/settings") {
|
||
|
|
t.Fatal("settings should not bypass")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestRequiresNativeEmailVerification(t *testing.T) {
|
||
|
|
if !requiresNativeEmailVerification(&entity.Member{Origin: entity.OriginNative}) {
|
||
|
|
t.Fatal("native should require verification")
|
||
|
|
}
|
||
|
|
if requiresNativeEmailVerification(&entity.Member{Origin: entity.OriginOAuth, EmailVerified: false}) {
|
||
|
|
t.Fatal("oauth should skip verification")
|
||
|
|
}
|
||
|
|
}
|