Merge branch 'master' into alias-fqdn

This commit is contained in:
Carlosokumu 2025-01-21 12:53:50 +03:00
commit 0b4fde9d1e
Signed by: carlos
GPG Key ID: 7BD6BC8160A5C953
4 changed files with 557 additions and 515 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1223,13 +1223,20 @@ func TestVerifyCreatePin(t *testing.T) {
},
}
// Hash the correct PIN
hashedPIN, err := pin.HashPIN("1234")
if err != nil {
logg.ErrorCtxf(ctx, "failed to hash temporaryPin", "error", err)
t.Fatal(err)
}
err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(hashedPIN))
if err != nil {
t.Fatal(err)
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte("1234"))
if err != nil {
t.Fatal(err)
}
// Call the method under test
res, err := h.VerifyCreatePin(ctx, "verify_create_pin", []byte(tt.input))
@ -1908,13 +1915,13 @@ func TestConfirmPin(t *testing.T) {
tests := []struct {
name string
input []byte
temporarypin []byte
temporarypin string
expectedResult resource.Result
}{
{
name: "Test with correct pin confirmation",
input: []byte("1234"),
temporarypin: []byte("1234"),
temporarypin: "1234",
expectedResult: resource.Result{
FlagReset: []uint32{flag_pin_mismatch},
},
@ -1922,14 +1929,21 @@ func TestConfirmPin(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Hash the PIN
hashedPIN, err := pin.HashPIN(tt.temporarypin)
if err != nil {
logg.ErrorCtxf(ctx, "failed to hash temporaryPin", "error", err)
t.Fatal(err)
}
// Set up the expected behavior of the mock
err := store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(tt.temporarypin))
err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(hashedPIN))
if err != nil {
t.Fatal(err)
}
//Call the function under test
res, _ := h.ConfirmPinChange(ctx, "confirm_pin_change", tt.temporarypin)
res, _ := h.ConfirmPinChange(ctx, "confirm_pin_change", tt.input)
//Assert that the result set to content is what was expected
assert.Equal(t, res, tt.expectedResult, "Result should contain flags set according to user input")

View File

@ -62,6 +62,7 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
}
//appHandlers = appHandlers.WithPersister(ls.Pe)
appHandlers.SetPersister(ls.Pe)
ls.DbRs.AddLocalFunc("check_blocked_status", appHandlers.CheckBlockedStatus)
ls.DbRs.AddLocalFunc("set_language", appHandlers.SetLanguage)
ls.DbRs.AddLocalFunc("create_account", appHandlers.CreateAccount)
ls.DbRs.AddLocalFunc("save_temporary_pin", appHandlers.SaveTemporaryPin)

View File

@ -1,9 +1,11 @@
LOAD check_blocked_status 1
RELOAD check_blocked_status
CATCH blocked_account flag_account_blocked 1
CATCH select_language flag_language_set 0
CATCH terms flag_account_created 0
LOAD check_account_status 0
RELOAD check_account_status
CATCH api_failure flag_api_call_error 1
CATCH api_failure flag_api_call_error 1
CATCH account_pending flag_account_pending 1
CATCH create_pin flag_pin_set 0
CATCH main flag_account_success 1