Compare commits

..

8 Commits

Author SHA1 Message Date
alfred-mk
fbfd81c94e removed the SetAccountFlags function to move it to sarafu-ussd-instance 2025-01-20 15:03:59 +03:00
alfred-mk
bad273fa58 removed leftover commented code 2025-01-20 10:56:12 +03:00
alfred-mk
ccd9e9cd77 Merge branch 'master' into data-migration 2025-01-20 10:43:17 +03:00
alfred-mk
cf27479fcf log the correct data key 2025-01-15 16:04:49 +03:00
alfred-mk
799d1a51fa add a fallback to swa for currently unsupported languages 2025-01-15 16:01:53 +03:00
alfred-mk
1376c7b8dd use the DATA_INITIAL_LANGUAGE_CODE to check the set language 2025-01-15 15:53:26 +03:00
alfred-mk
b70d6b54d1 Merge branch 'master' into data-migration 2025-01-15 11:00:08 +03:00
alfred-mk
46544b723b Added SetAccountFlags to check the available data and set the required flags 2025-01-15 10:59:02 +03:00
5 changed files with 515 additions and 529 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -265,7 +265,6 @@ func TestWithPersister(t *testing.T) {
h.SetPersister(p)
assert.Equal(t, p, h.pe, "The persister should be set correctly.")
//assert.Equal(t, h, result, "The returned handler should be the same instance.")
}
func TestWithPersister_PanicWhenAlreadySet(t *testing.T) {
@@ -1223,20 +1222,13 @@ 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))
@@ -1915,13 +1907,13 @@ func TestConfirmPin(t *testing.T) {
tests := []struct {
name string
input []byte
temporarypin string
temporarypin []byte
expectedResult resource.Result
}{
{
name: "Test with correct pin confirmation",
input: []byte("1234"),
temporarypin: "1234",
temporarypin: []byte("1234"),
expectedResult: resource.Result{
FlagReset: []uint32{flag_pin_mismatch},
},
@@ -1929,21 +1921,14 @@ 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(hashedPIN))
err := store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(tt.temporarypin))
if err != nil {
t.Fatal(err)
}
//Call the function under test
res, _ := h.ConfirmPinChange(ctx, "confirm_pin_change", tt.input)
res, _ := h.ConfirmPinChange(ctx, "confirm_pin_change", tt.temporarypin)
//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

@@ -60,7 +60,6 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
if err != nil {
return nil, err
}
//appHandlers = appHandlers.WithPersister(ls.Pe)
appHandlers.SetPersister(ls.Pe)
ls.DbRs.AddLocalFunc("set_language", appHandlers.SetLanguage)
ls.DbRs.AddLocalFunc("create_account", appHandlers.CreateAccount)

View File

@@ -3,7 +3,7 @@ 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

View File

@@ -3,7 +3,7 @@ RELOAD transaction_reset
CATCH no_voucher flag_no_active_voucher 1
MOUT back 0
HALT
LOAD validate_recipient 50
LOAD validate_recipient 20
RELOAD validate_recipient
CATCH invalid_recipient flag_invalid_recipient 1
CATCH invite_recipient flag_invalid_recipient_with_invite 1