diff --git a/pkg/authmechs/authmechs_test.go b/pkg/authmechs/authmechs_test.go index 9439b0a..53fd1ce 100644 --- a/pkg/authmechs/authmechs_test.go +++ b/pkg/authmechs/authmechs_test.go @@ -26,12 +26,63 @@ func TestRemoveMechsInDB(t *testing.T) { mechList: []string{"mech1", "mech2"}, want: AuthDB{Mechanisms: []string{"mech3"}}, }, + { + name: "Test with non-empty db and mechList where the removed mechs are at the end of the slice", + db: AuthDB{Mechanisms: []string{"mech1", "mech2", "mech3"}}, + mechList: []string{"mech2", "mech3"}, + want: AuthDB{Mechanisms: []string{"mech1"}}, + }, { name: "Test with non-empty db and empty mechList", db: AuthDB{Mechanisms: []string{"mech1", "mech2", "mech3"}}, mechList: []string{}, want: AuthDB{Mechanisms: []string{"mech1", "mech2", "mech3"}}, }, + { + name: "Test with real data on device updated from python Crypt", + db: AuthDB{Mechanisms: []string{ + "builtin:prelogin", + "builtin:policy-banner", + "loginwindow:login", + "builtin:login-begin", + "builtin:reset-password,privileged", + "loginwindow:FDESupport,privileged", + "builtin:forward-login,privileged", + "builtin:auto-login,privileged", + "builtin:authenticate,privileged", + "PKINITMechanism:auth,privileged", + "builtin:login-success", + "loginwindow:success", + "HomeDirMechanism:login,privileged", + "HomeDirMechanism:status", + "MCXMechanism:login", + "CryptoTokenKit:login", + "loginwindow:done", + "Crypt:Check,privileged", + "Crypt:CryptGUI", + "Crypt:Enablement,privileged", + }}, + mechList: []string{"Crypt:Check,privileged", "Crypt:CryptGUI", "Crypt:Enablement,privileged"}, + want: AuthDB{Mechanisms: []string{ + "builtin:prelogin", + "builtin:policy-banner", + "loginwindow:login", + "builtin:login-begin", + "builtin:reset-password,privileged", + "loginwindow:FDESupport,privileged", + "builtin:forward-login,privileged", + "builtin:auto-login,privileged", + "builtin:authenticate,privileged", + "PKINITMechanism:auth,privileged", + "builtin:login-success", + "loginwindow:success", + "HomeDirMechanism:login,privileged", + "HomeDirMechanism:status", + "MCXMechanism:login", + "CryptoTokenKit:login", + "loginwindow:done", + }}, + }, } for _, tt := range tests {