36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
|
|
package fadada
|
||
|
|
|
||
|
|
import "testing"
|
||
|
|
|
||
|
|
func TestValidateEnterpriseAuthRequest(t *testing.T) {
|
||
|
|
err := validateEnterpriseAuthRequest(&EnterpriseAuthRequest{
|
||
|
|
CompanyName: "测试企业有限公司",
|
||
|
|
UnifiedSocialCode: "91110000MA01234567",
|
||
|
|
LegalPersonName: "张三",
|
||
|
|
TransactorName: "张三",
|
||
|
|
TransactorMobile: "13800138000",
|
||
|
|
TransactorID: "110101199001011234",
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
t.Fatalf("expected nil, got %v", err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := validateEnterpriseAuthRequest(nil); err == nil {
|
||
|
|
t.Fatal("expected error for nil request")
|
||
|
|
}
|
||
|
|
if err := validateEnterpriseAuthRequest(&EnterpriseAuthRequest{}); err == nil {
|
||
|
|
t.Fatal("expected error for empty request")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestEncodeRedirectURL(t *testing.T) {
|
||
|
|
raw := "http://localhost:5173/profile/certification"
|
||
|
|
encoded := encodeRedirectURL(raw)
|
||
|
|
if encoded == "" || encoded == raw {
|
||
|
|
t.Fatalf("expected url-encoded redirect, got %q", encoded)
|
||
|
|
}
|
||
|
|
if encodeRedirectURL(encoded) != encoded {
|
||
|
|
t.Fatalf("already-encoded url should stay unchanged")
|
||
|
|
}
|
||
|
|
}
|