diff --git a/handlers/application/menuhandler.go b/handlers/application/menuhandler.go index 19cc266..b1e8109 100644 --- a/handlers/application/menuhandler.go +++ b/handlers/application/menuhandler.go @@ -340,29 +340,6 @@ func (h *MenuHandlers) ResetIncorrectPin(ctx context.Context, sym string, input return res, nil } -// VerifyNewPin checks if a new PIN meets the required format criteria. -func (h *MenuHandlers) VerifyNewPin(ctx context.Context, sym string, input []byte) (resource.Result, error) { - res := resource.Result{} - _, ok := ctx.Value("SessionId").(string) - if !ok { - return res, fmt.Errorf("missing session") - } - flag_valid_pin, _ := h.flagManager.GetFlag("flag_valid_pin") - if string(input) != "0" { - pinInput := string(input) - // Validate that the PIN is a 4-digit number. - if pin.IsValidPIN(pinInput) { - res.FlagSet = append(res.FlagSet, flag_valid_pin) - } else { - res.FlagReset = append(res.FlagReset, flag_valid_pin) - } - } else { - res.FlagSet = append(res.FlagSet, flag_valid_pin) - } - - return res, nil -} - // SaveTemporaryPin saves the valid PIN input to the DATA_TEMPORARY_VALUE, // during the account creation process // and during the change PIN process. diff --git a/handlers/application/menuhandler_test.go b/handlers/application/menuhandler_test.go index d903efc..9a7bc75 100644 --- a/handlers/application/menuhandler_test.go +++ b/handlers/application/menuhandler_test.go @@ -1843,52 +1843,6 @@ func TestGetProfile(t *testing.T) { } } -func TestVerifyNewPin(t *testing.T) { - sessionId := "session123" - - fm, _ := NewFlagManager(flagsPath) - mockState := state.NewState(16) - - flag_valid_pin, _ := fm.GetFlag("flag_valid_pin") - mockAccountService := new(mocks.MockAccountService) - h := &MenuHandlers{ - flagManager: fm, - accountService: mockAccountService, - st: mockState, - } - ctx := context.WithValue(context.Background(), "SessionId", sessionId) - - tests := []struct { - name string - input []byte - expectedResult resource.Result - }{ - { - name: "Test with valid pin", - input: []byte("1234"), - expectedResult: resource.Result{ - FlagSet: []uint32{flag_valid_pin}, - }, - }, - { - name: "Test with invalid pin", - input: []byte("123"), - expectedResult: resource.Result{ - FlagReset: []uint32{flag_valid_pin}, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - //Call the function under test - res, _ := h.VerifyNewPin(ctx, "verify_new_pin", 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") - }) - } -} - func TestConfirmPinChange(t *testing.T) { sessionId := "session123" diff --git a/handlers/local.go b/handlers/local.go index 46a887c..51f4208 100644 --- a/handlers/local.go +++ b/handlers/local.go @@ -99,7 +99,6 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService) ls.DbRs.AddLocalFunc("verify_yob", appHandlers.VerifyYob) ls.DbRs.AddLocalFunc("reset_incorrect_date_format", appHandlers.ResetIncorrectYob) ls.DbRs.AddLocalFunc("initiate_transaction", appHandlers.InitiateTransaction) - ls.DbRs.AddLocalFunc("verify_new_pin", appHandlers.VerifyNewPin) ls.DbRs.AddLocalFunc("confirm_pin_change", appHandlers.ConfirmPinChange) ls.DbRs.AddLocalFunc("quit_with_help", appHandlers.QuitWithHelp) ls.DbRs.AddLocalFunc("fetch_community_balance", appHandlers.FetchCommunityBalance) diff --git a/services/registration/new_pin.vis b/services/registration/new_pin.vis index 54f23ec..79e95ea 100644 --- a/services/registration/new_pin.vis +++ b/services/registration/new_pin.vis @@ -2,6 +2,5 @@ MOUT back 0 HALT INCMP _ 0 RELOAD save_temporary_pin -RELOAD verify_new_pin CATCH invalid_pin flag_invalid_pin 1 INCMP confirm_pin_change * diff --git a/services/registration/pin_management.vis b/services/registration/pin_management.vis index ca54ee4..01bd236 100644 --- a/services/registration/pin_management.vis +++ b/services/registration/pin_management.vis @@ -1,7 +1,6 @@ LOAD set_back 6 LOAD authorize_account 16 LOAD reset_allow_update 4 -LOAD verify_new_pin 2 LOAD save_temporary_pin 1 LOAD reset_incorrect 0 LOAD reset_invalid_pin 6 diff --git a/services/registration/self_reset_pin.vis b/services/registration/self_reset_pin.vis index 5fa328f..401a4e0 100644 --- a/services/registration/self_reset_pin.vis +++ b/services/registration/self_reset_pin.vis @@ -2,7 +2,5 @@ LOAD reset_invalid_pin 6 HALT LOAD save_temporary_pin 1 RELOAD save_temporary_pin -LOAD verify_new_pin 2 -RELOAD verify_new_pin CATCH invalid_pin flag_invalid_pin 1 INCMP confirm_pin_change *