GODT-1657: More stable sync, with some tests

This commit is contained in:
James Houlahan
2022-10-09 23:05:52 +02:00
parent e7526f2e78
commit 509a767e50
41 changed files with 883 additions and 779 deletions

View File

@ -138,3 +138,12 @@ func (user *User) SetEventID(eventID string) error {
data.EventID = eventID
})
}
// Clear clears the user's auth secrets.
func (user *User) Clear() error {
return user.vault.modUser(user.userID, func(data *UserData) {
data.AuthUID = ""
data.AuthRef = ""
data.KeyPass = nil
})
}

View File

@ -58,7 +58,7 @@ func TestUser_Clear(t *testing.T) {
require.Equal(t, "keyPass", string(user.KeyPass()))
// Clear the user's auth information.
require.NoError(t, s.ClearUser("userID"))
require.NoError(t, user.Clear())
// Check the user's cleared auth information.
require.Empty(t, user.AuthUID())

View File

@ -107,14 +107,6 @@ func (vault *Vault) AddUser(userID, username, authUID, authRef string, keyPass [
return vault.GetUser(userID)
}
func (vault *Vault) ClearUser(userID string) error {
return vault.modUser(userID, func(data *UserData) {
data.AuthUID = ""
data.AuthRef = ""
data.KeyPass = nil
})
}
// DeleteUser removes the given user from the vault.
func (vault *Vault) DeleteUser(userID string) error {
return vault.mod(func(data *Data) {