feat: merge registration invite and verification input
This commit is contained in:
+20
-7
@@ -1321,6 +1321,8 @@ func TestDispatchAccNew(t *testing.T) {
|
||||
oldSecurity := store.Security
|
||||
oldVerifications := store.Verifications
|
||||
oldInvites := store.RegistrationInvites
|
||||
oldValidators := globals.validators
|
||||
globals.validators = map[string]credValidator{"tel": {}}
|
||||
store.Store = ss
|
||||
store.Users = uu
|
||||
store.Security = &testSecurityStore{version: 1}
|
||||
@@ -1329,12 +1331,15 @@ func TestDispatchAccNew(t *testing.T) {
|
||||
Code: "AbCdE", Status: types.RegistrationInviteActive, ExpiresAt: time.Now().Add(time.Hour),
|
||||
}}
|
||||
store.RegistrationInvites = invites
|
||||
setRegistrationSMSConfigForTest(true)
|
||||
defer func() {
|
||||
store.Store = nil
|
||||
store.Users = nil
|
||||
store.Security = oldSecurity
|
||||
store.Verifications = oldVerifications
|
||||
store.RegistrationInvites = oldInvites
|
||||
globals.validators = oldValidators
|
||||
resetRegistrationSMSConfigForTest()
|
||||
ctrl.Finish()
|
||||
}()
|
||||
|
||||
@@ -1347,10 +1352,14 @@ func TestDispatchAccNew(t *testing.T) {
|
||||
State: types.StateOK,
|
||||
}
|
||||
ss.EXPECT().GetLogicalAuthHandler("basic").Return(aa)
|
||||
ss.EXPECT().GetValidator("tel").Return(registrationTestValidator{})
|
||||
// This login is available.
|
||||
aa.EXPECT().IsUnique(auth.AuthContext{TenantID: 1, RemoteAddr: remoteAddr}, []byte(secret)).Return(true, nil)
|
||||
uu.EXPECT().Create(types.TenantID(1), gomock.Any(), gomock.Any()).DoAndReturn(
|
||||
func(_ types.TenantID, user *types.User, private any) (*types.User, error) {
|
||||
if user.Phone != "+8613800138000" {
|
||||
t.Fatalf("unexpected registration phone: %q", user.Phone)
|
||||
}
|
||||
user.SetUid(uid)
|
||||
return user, nil
|
||||
})
|
||||
@@ -1378,13 +1387,17 @@ func TestDispatchAccNew(t *testing.T) {
|
||||
public := "public name"
|
||||
msg := &ClientComMessage{
|
||||
Acc: &MsgClientAcc{
|
||||
Id: "123",
|
||||
User: "newXYZ",
|
||||
Scheme: "basic",
|
||||
Username: "alice",
|
||||
InviteCode: "AbCdE",
|
||||
Secret: []byte(secret),
|
||||
Desc: &MsgSetDesc{Public: public},
|
||||
Id: "123",
|
||||
User: "newXYZ",
|
||||
Scheme: "basic",
|
||||
Username: "alice",
|
||||
Phone: "13800138000",
|
||||
Secret: []byte(secret),
|
||||
Cred: []MsgCredClient{{
|
||||
Method: "tel", Value: "+8613800138000", Response: "AbCdE",
|
||||
Params: map[string]any{"challenge_id": "challenge-1"},
|
||||
}},
|
||||
Desc: &MsgSetDesc{Public: public},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user