feat: complete registration invitation and auth redesign
This commit is contained in:
+17
-6
@@ -1237,20 +1237,26 @@ func TestDispatchAccNew(t *testing.T) {
|
||||
uid := types.Uid(1)
|
||||
oldSecurity := store.Security
|
||||
oldVerifications := store.Verifications
|
||||
oldInvites := store.RegistrationInvites
|
||||
store.Store = ss
|
||||
store.Users = uu
|
||||
store.Security = &testSecurityStore{version: 1}
|
||||
store.Verifications = nil
|
||||
invites := &testRegistrationInviteStore{invite: &types.RegistrationInviteCode{
|
||||
Code: "AbCdE", Status: types.RegistrationInviteActive, ExpiresAt: time.Now().Add(time.Hour),
|
||||
}}
|
||||
store.RegistrationInvites = invites
|
||||
defer func() {
|
||||
store.Store = nil
|
||||
store.Users = nil
|
||||
store.Security = oldSecurity
|
||||
store.Verifications = oldVerifications
|
||||
store.RegistrationInvites = oldInvites
|
||||
ctrl.Finish()
|
||||
}()
|
||||
|
||||
remoteAddr := "192.168.0.1"
|
||||
secret := "<==auth-secret==>"
|
||||
secret := "alice:password"
|
||||
authRec := &auth.Rec{
|
||||
TenantID: 1,
|
||||
Uid: uid,
|
||||
@@ -1289,11 +1295,13 @@ func TestDispatchAccNew(t *testing.T) {
|
||||
public := "public name"
|
||||
msg := &ClientComMessage{
|
||||
Acc: &MsgClientAcc{
|
||||
Id: "123",
|
||||
User: "newXYZ",
|
||||
Scheme: "basic",
|
||||
Secret: []byte(secret),
|
||||
Desc: &MsgSetDesc{Public: public},
|
||||
Id: "123",
|
||||
User: "newXYZ",
|
||||
Scheme: "basic",
|
||||
Username: "alice",
|
||||
InviteCode: "AbCdE",
|
||||
Secret: []byte(secret),
|
||||
Desc: &MsgSetDesc{Public: public},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1304,6 +1312,9 @@ func TestDispatchAccNew(t *testing.T) {
|
||||
if len(r.messages) != 1 {
|
||||
t.Errorf("responses: expected 1, received %d.", len(r.messages))
|
||||
}
|
||||
if !invites.useRecorded {
|
||||
t.Error("registration invite use was not recorded")
|
||||
}
|
||||
resp := r.messages[0].(*ServerComMessage)
|
||||
if resp == nil {
|
||||
t.Fatal("Response must be ServerComMessage")
|
||||
|
||||
Reference in New Issue
Block a user