37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package config
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"strings"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestTencentSMSConfigRequiresCompleteCredentialsAndApprovedTemplate(t *testing.T) {
|
||
|
|
c := OnboardingConfig{
|
||
|
|
SMSLoginEnabled: true,
|
||
|
|
SMSProvider: "tencent",
|
||
|
|
MasterKey: strings.Repeat("ab", 32),
|
||
|
|
EntryURL: "https://platform.example/onboarding/entry",
|
||
|
|
TencentSMSSecretID: "id",
|
||
|
|
TencentSMSSecretKey: "key",
|
||
|
|
TencentSMSAppID: "1400006666",
|
||
|
|
TencentSMSSignName: "安芯伴",
|
||
|
|
TencentSMSTemplateID: "123456",
|
||
|
|
}
|
||
|
|
if err := c.validate(EnvironmentProd); err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
c.TencentSMSSecretKey = ""
|
||
|
|
if err := c.validate(EnvironmentProd); err == nil {
|
||
|
|
t.Fatal("Tencent SMS accepted a missing secret key")
|
||
|
|
}
|
||
|
|
c.TencentSMSSecretKey = "key"
|
||
|
|
c.TencentSMSTemplateID = "unapproved"
|
||
|
|
if err := c.validate(EnvironmentProd); err == nil {
|
||
|
|
t.Fatal("Tencent SMS accepted an invalid template ID")
|
||
|
|
}
|
||
|
|
c.SMSProvider = "unknown"
|
||
|
|
if err := c.validate(EnvironmentProd); err == nil {
|
||
|
|
t.Fatal("unknown SMS provider accepted")
|
||
|
|
}
|
||
|
|
}
|