remove the verify_new_pin functionality that managed the unused flag_valid_pin
This commit is contained in:
		
							parent
							
								
									7d9c3b66a9
								
							
						
					
					
						commit
						57a1645c03
					
				@ -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.
 | 
			
		||||
 | 
			
		||||
@ -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"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
@ -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 *
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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 * 
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user