Compare commits
45 Commits
lash/threa
...
tests-upda
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3ff3be5b1
|
||
|
|
ea52a7cf0a
|
||
|
|
a993026380
|
||
|
|
4ee241714b
|
||
|
|
d7dc743fa2 | ||
|
|
c220cbb767
|
||
| 0dc322729f | |||
| 726d6dd338 | |||
| a8b202bd79 | |||
|
|
6dbd250694
|
||
|
|
cc760e7698
|
||
|
|
8648ea599c
|
||
|
|
77e4c5d43a
|
||
|
|
b15ba367c4
|
||
|
|
4db862bc97
|
||
|
|
6ad67f6adc
|
||
| 0caf82a27e | |||
| a430857309 | |||
|
|
2643c0c9ff
|
||
|
|
b8852e1ab3
|
||
|
|
0dea34daab
|
||
|
|
8057313c78
|
||
|
|
1bd96d0689
|
||
|
|
bbfe46f162
|
||
|
|
eff2cbde8b
|
||
|
|
5c85ecffd1
|
||
|
|
ad1f9233ca | ||
| e9fdd1ddbe | |||
|
|
8a03b05c90
|
||
|
|
c18c40b1b8 | ||
|
|
5a38b40eaf | ||
|
|
909d1f3409
|
||
|
|
66cf90f044
|
||
|
|
74d5da3987 | ||
|
|
f215159725
|
||
|
|
a6301163eb
|
||
|
|
a07fce527f | ||
|
|
ddc8f6dad1
|
||
|
|
c2b68231f5
|
||
|
|
3f3dbf414c
|
||
|
|
e4c3e9f015
|
||
|
|
9b71244391 | ||
|
|
ada1f26b68
|
||
|
|
935b777e57
|
||
|
|
19372c17f4
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,3 +4,5 @@ go.work*
|
||||
**/*/*.bin
|
||||
**/*/.state/
|
||||
cmd/.state/
|
||||
id_*
|
||||
*.gdbm
|
||||
|
||||
@@ -69,13 +69,11 @@ func main() {
|
||||
var resourceDir string
|
||||
var size uint
|
||||
var engineDebug bool
|
||||
var stateDebug bool
|
||||
var host string
|
||||
var port uint
|
||||
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
|
||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
||||
flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output")
|
||||
flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output")
|
||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||
flag.UintVar(&size, "s", 160, "max size of output")
|
||||
flag.StringVar(&host, "h", "127.0.0.1", "http host")
|
||||
flag.UintVar(&port, "p", 7123, "http port")
|
||||
@@ -91,9 +89,7 @@ func main() {
|
||||
OutputSize: uint32(size),
|
||||
FlagCount: uint32(16),
|
||||
}
|
||||
if stateDebug {
|
||||
cfg.StateDebug = true
|
||||
}
|
||||
|
||||
if engineDebug {
|
||||
cfg.EngineDebug = true
|
||||
}
|
||||
|
||||
@@ -41,14 +41,12 @@ func main() {
|
||||
var resourceDir string
|
||||
var size uint
|
||||
var engineDebug bool
|
||||
var stateDebug bool
|
||||
var host string
|
||||
var port uint
|
||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
|
||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
||||
flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output")
|
||||
flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output")
|
||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||
flag.UintVar(&size, "s", 160, "max size of output")
|
||||
flag.StringVar(&host, "h", "127.0.0.1", "http host")
|
||||
flag.UintVar(&port, "p", 7123, "http port")
|
||||
@@ -64,9 +62,7 @@ func main() {
|
||||
OutputSize: uint32(size),
|
||||
FlagCount: uint32(16),
|
||||
}
|
||||
if stateDebug {
|
||||
cfg.StateDebug = true
|
||||
}
|
||||
|
||||
if engineDebug {
|
||||
cfg.EngineDebug = true
|
||||
}
|
||||
|
||||
@@ -30,13 +30,11 @@ func main() {
|
||||
var resourceDir string
|
||||
var size uint
|
||||
var engineDebug bool
|
||||
var stateDebug bool
|
||||
var host string
|
||||
var port uint
|
||||
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
|
||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
||||
flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output")
|
||||
flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output")
|
||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||
flag.UintVar(&size, "s", 160, "max size of output")
|
||||
flag.StringVar(&host, "h", "127.0.0.1", "http host")
|
||||
flag.UintVar(&port, "p", 7123, "http port")
|
||||
@@ -52,9 +50,7 @@ func main() {
|
||||
OutputSize: uint32(size),
|
||||
FlagCount: uint32(16),
|
||||
}
|
||||
if stateDebug {
|
||||
cfg.StateDebug = true
|
||||
}
|
||||
|
||||
if engineDebug {
|
||||
cfg.EngineDebug = true
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ func main() {
|
||||
var dbDir string
|
||||
var size uint
|
||||
var sessionId string
|
||||
var debug bool
|
||||
var engineDebug bool
|
||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
|
||||
flag.BoolVar(&debug, "d", false, "use engine debug output")
|
||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||
flag.UintVar(&size, "s", 160, "max size of output")
|
||||
flag.Parse()
|
||||
|
||||
@@ -93,7 +93,7 @@ func main() {
|
||||
|
||||
en := lhs.GetEngine()
|
||||
en = en.WithFirst(hl.Init)
|
||||
if debug {
|
||||
if engineDebug {
|
||||
en = en.WithDebug(nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,6 @@ func (ls *LocalHandlerService) GetHandler() (*ussd.Handlers, error) {
|
||||
ls.DbRs.AddLocalFunc("get_profile_info", ussdHandlers.GetProfileInfo)
|
||||
ls.DbRs.AddLocalFunc("verify_yob", ussdHandlers.VerifyYob)
|
||||
ls.DbRs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob)
|
||||
ls.DbRs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
|
||||
ls.DbRs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
|
||||
ls.DbRs.AddLocalFunc("save_temporary_pin", ussdHandlers.SaveTemporaryPin)
|
||||
ls.DbRs.AddLocalFunc("verify_new_pin", ussdHandlers.VerifyNewPin)
|
||||
|
||||
@@ -117,17 +117,14 @@ func (h *Handlers) Init(ctx context.Context, sym string, input []byte) (resource
|
||||
func (h *Handlers) SetLanguage(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
var res resource.Result
|
||||
|
||||
sym, _ = h.st.Where()
|
||||
symbol, _ := h.st.Where()
|
||||
code := strings.Split(symbol, "_")[1]
|
||||
|
||||
switch sym {
|
||||
case "set_default":
|
||||
res.FlagSet = append(res.FlagSet, state.FLAG_LANG)
|
||||
res.Content = "eng"
|
||||
case "set_swa":
|
||||
res.FlagSet = append(res.FlagSet, state.FLAG_LANG)
|
||||
res.Content = "swa"
|
||||
default:
|
||||
if !utils.IsValidISO639(code) {
|
||||
return res, nil
|
||||
}
|
||||
res.FlagSet = append(res.FlagSet, state.FLAG_LANG)
|
||||
res.Content = code
|
||||
|
||||
languageSetFlag, err := h.flagManager.GetFlag("flag_language_set")
|
||||
if err != nil {
|
||||
@@ -279,32 +276,6 @@ func (h *Handlers) ConfirmPinChange(ctx context.Context, sym string, input []byt
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// SetResetSingleEdit sets and resets flags to allow gradual editing of profile information.
|
||||
func (h *Handlers) SetResetSingleEdit(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
var res resource.Result
|
||||
|
||||
menuOption := string(input)
|
||||
|
||||
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
|
||||
flag_single_edit, _ := h.flagManager.GetFlag("flag_single_edit")
|
||||
|
||||
switch menuOption {
|
||||
case "2":
|
||||
res.FlagReset = append(res.FlagReset, flag_allow_update)
|
||||
res.FlagSet = append(res.FlagSet, flag_single_edit)
|
||||
case "3":
|
||||
res.FlagReset = append(res.FlagReset, flag_allow_update)
|
||||
res.FlagSet = append(res.FlagSet, flag_single_edit)
|
||||
case "4":
|
||||
res.FlagReset = append(res.FlagReset, flag_allow_update)
|
||||
res.FlagSet = append(res.FlagSet, flag_single_edit)
|
||||
default:
|
||||
res.FlagReset = append(res.FlagReset, flag_single_edit)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// VerifyPin checks whether the confirmation PIN is similar to the account PIN
|
||||
// If similar, it sets the USERFLAG_PIN_SET flag allowing the user
|
||||
// to access the main menu
|
||||
@@ -435,6 +406,7 @@ func (h *Handlers) SaveLocation(ctx context.Context, sym string, input []byte) (
|
||||
|
||||
// SaveGender updates the gender in the gdbm with the provided input.
|
||||
func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
symbol, _ := h.st.Where()
|
||||
var res resource.Result
|
||||
var err error
|
||||
sessionId, ok := ctx.Value("SessionId").(string)
|
||||
@@ -442,21 +414,11 @@ func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (re
|
||||
return res, fmt.Errorf("missing session")
|
||||
}
|
||||
|
||||
if len(input) > 0 {
|
||||
gender := string(input)
|
||||
switch gender {
|
||||
case "1":
|
||||
gender = "Male"
|
||||
case "2":
|
||||
gender = "Female"
|
||||
case "3":
|
||||
gender = "Unspecified"
|
||||
}
|
||||
store := h.userdataStore
|
||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_GENDER, []byte(gender))
|
||||
if err != nil {
|
||||
return res, nil
|
||||
}
|
||||
gender := strings.Split(symbol, "_")[1]
|
||||
store := h.userdataStore
|
||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_GENDER, []byte(gender))
|
||||
if err != nil {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"git.defalsify.org/vise.git/db"
|
||||
"git.defalsify.org/vise.git/persist"
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
"git.defalsify.org/vise.git/state"
|
||||
"git.grassecon.net/urdt/ussd/internal/mocks"
|
||||
@@ -16,6 +17,7 @@ import (
|
||||
"git.grassecon.net/urdt/ussd/internal/utils"
|
||||
"github.com/alecthomas/assert/v2"
|
||||
testdataloader "github.com/peteole/testdata-loader"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -94,6 +96,25 @@ func TestCreateAccount(t *testing.T) {
|
||||
mockDataStore.AssertExpectations(t)
|
||||
}
|
||||
|
||||
func TestWithPersister(t *testing.T) {
|
||||
// Test case: Setting a persister
|
||||
h := &Handlers{}
|
||||
p := &persist.Persister{}
|
||||
|
||||
result := h.WithPersister(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) {
|
||||
// Test case: Panic on multiple calls
|
||||
h := &Handlers{pe: &persist.Persister{}}
|
||||
require.Panics(t, func() {
|
||||
h.WithPersister(&persist.Persister{})
|
||||
}, "Should panic when trying to set a persister again.")
|
||||
}
|
||||
|
||||
func TestSaveFirstname(t *testing.T) {
|
||||
// Create a new instance of MockMyDataStore
|
||||
mockStore := new(mocks.MockUserDataStore)
|
||||
@@ -295,6 +316,7 @@ func TestSaveOfferings(t *testing.T) {
|
||||
func TestSaveGender(t *testing.T) {
|
||||
// Create a new instance of MockMyDataStore
|
||||
mockStore := new(mocks.MockUserDataStore)
|
||||
mockState := state.NewState(16)
|
||||
|
||||
// Define the session ID and context
|
||||
sessionId := "session123"
|
||||
@@ -302,34 +324,32 @@ func TestSaveGender(t *testing.T) {
|
||||
|
||||
// Define test cases
|
||||
tests := []struct {
|
||||
name string
|
||||
input []byte
|
||||
expectedGender string
|
||||
expectCall bool
|
||||
name string
|
||||
input []byte
|
||||
expectedGender string
|
||||
expectCall bool
|
||||
executingSymbol string
|
||||
}{
|
||||
{
|
||||
name: "Valid Male Input",
|
||||
input: []byte("1"),
|
||||
expectedGender: "Male",
|
||||
expectCall: true,
|
||||
name: "Valid Male Input",
|
||||
input: []byte("1"),
|
||||
expectedGender: "male",
|
||||
executingSymbol: "set_male",
|
||||
expectCall: true,
|
||||
},
|
||||
{
|
||||
name: "Valid Female Input",
|
||||
input: []byte("2"),
|
||||
expectedGender: "Female",
|
||||
expectCall: true,
|
||||
name: "Valid Female Input",
|
||||
input: []byte("2"),
|
||||
expectedGender: "female",
|
||||
executingSymbol: "set_female",
|
||||
expectCall: true,
|
||||
},
|
||||
{
|
||||
name: "Valid Unspecified Input",
|
||||
input: []byte("3"),
|
||||
expectedGender: "Unspecified",
|
||||
expectCall: true,
|
||||
},
|
||||
{
|
||||
name: "Empty Input",
|
||||
input: []byte(""),
|
||||
expectedGender: "",
|
||||
expectCall: false,
|
||||
name: "Valid Unspecified Input",
|
||||
input: []byte("3"),
|
||||
executingSymbol: "set_unspecified",
|
||||
expectedGender: "unspecified",
|
||||
expectCall: true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -342,14 +362,15 @@ func TestSaveGender(t *testing.T) {
|
||||
} else {
|
||||
mockStore.On("WriteEntry", ctx, sessionId, utils.DATA_GENDER, []byte(tt.expectedGender)).Return(nil)
|
||||
}
|
||||
|
||||
mockState.ExecPath = append(mockState.ExecPath, tt.executingSymbol)
|
||||
// Create the Handlers instance with the mock store
|
||||
h := &Handlers{
|
||||
userdataStore: mockStore,
|
||||
st: mockState,
|
||||
}
|
||||
|
||||
// Call the method
|
||||
_, err := h.SaveGender(ctx, "someSym", tt.input)
|
||||
_, err := h.SaveGender(ctx, "save_gender", tt.input)
|
||||
|
||||
// Assert no error
|
||||
assert.NoError(t, err)
|
||||
@@ -538,13 +559,13 @@ func TestSetLanguage(t *testing.T) {
|
||||
}
|
||||
// Define test cases
|
||||
tests := []struct {
|
||||
name string
|
||||
execPath []string
|
||||
expectedResult resource.Result
|
||||
name string
|
||||
execPath []string
|
||||
expectedResult resource.Result
|
||||
}{
|
||||
{
|
||||
name: "Set Default Language (English)",
|
||||
execPath: []string{"set_default"},
|
||||
execPath: []string{"set_eng"},
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{state.FLAG_LANG, 8},
|
||||
Content: "eng",
|
||||
@@ -558,13 +579,6 @@ func TestSetLanguage(t *testing.T) {
|
||||
Content: "swa",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Unhandled path",
|
||||
execPath: []string{""},
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{8},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
@@ -592,76 +606,6 @@ func TestSetLanguage(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetResetSingleEdit(t *testing.T) {
|
||||
fm, err := NewFlagManager(flagsPath)
|
||||
|
||||
flag_allow_update, _ := fm.parser.GetFlag("flag_allow_update")
|
||||
flag_single_edit, _ := fm.parser.GetFlag("flag_single_edit")
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// Define test cases
|
||||
tests := []struct {
|
||||
name string
|
||||
input []byte
|
||||
expectedResult resource.Result
|
||||
}{
|
||||
{
|
||||
name: "Set single Edit",
|
||||
input: []byte("2"),
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{flag_single_edit},
|
||||
FlagReset: []uint32{flag_allow_update},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Set single Edit",
|
||||
input: []byte("3"),
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{flag_single_edit},
|
||||
FlagReset: []uint32{flag_allow_update},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Set single edit",
|
||||
input: []byte("4"),
|
||||
expectedResult: resource.Result{
|
||||
FlagReset: []uint32{flag_allow_update},
|
||||
FlagSet: []uint32{flag_single_edit},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "No single edit set",
|
||||
input: []byte("1"),
|
||||
expectedResult: resource.Result{
|
||||
FlagReset: []uint32{flag_single_edit},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
// Create the Handlers instance with the mock flag manager
|
||||
h := &Handlers{
|
||||
flagManager: fm.parser,
|
||||
}
|
||||
|
||||
// Call the method
|
||||
res, err := h.SetResetSingleEdit(context.Background(), "set_reset_single_edit", tt.input)
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
// Assert that the Result FlagSet has the required flags after language switch
|
||||
assert.Equal(t, res, tt.expectedResult, "Flags should match reset edit")
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestResetAllowUpdate(t *testing.T) {
|
||||
fm, err := NewFlagManager(flagsPath)
|
||||
|
||||
@@ -1480,7 +1424,7 @@ func TestValidateAmount(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Logf(err.Error())
|
||||
}
|
||||
//flag_invalid_amount, _ := fm.parser.GetFlag("flag_invalid_amount")
|
||||
flag_invalid_amount, _ := fm.parser.GetFlag("flag_invalid_amount")
|
||||
mockDataStore := new(mocks.MockUserDataStore)
|
||||
mockCreateAccountService := new(mocks.MockAccountService)
|
||||
|
||||
@@ -1509,26 +1453,26 @@ func TestValidateAmount(t *testing.T) {
|
||||
Content: "0.001",
|
||||
},
|
||||
},
|
||||
// {
|
||||
// name: "Test with amount larger than balance",
|
||||
// input: []byte("0.02"),
|
||||
// balance: "0.003 CELO",
|
||||
// publicKey: []byte("0xrqeqrequuq"),
|
||||
// expectedResult: resource.Result{
|
||||
// FlagSet: []uint32{flag_invalid_amount},
|
||||
// Content: "0.02",
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// name: "Test with invalid amount",
|
||||
// input: []byte("0.02ms"),
|
||||
// balance: "0.003 CELO",
|
||||
// publicKey: []byte("0xrqeqrequuq"),
|
||||
// expectedResult: resource.Result{
|
||||
// FlagSet: []uint32{flag_invalid_amount},
|
||||
// Content: "0.02ms",
|
||||
// },
|
||||
// },
|
||||
{
|
||||
name: "Test with amount larger than balance",
|
||||
input: []byte("0.02"),
|
||||
balance: "0.003 CELO",
|
||||
publicKey: []byte("0xrqeqrequuq"),
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{flag_invalid_amount},
|
||||
Content: "0.02",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Test with invalid amount",
|
||||
input: []byte("0.02ms"),
|
||||
balance: "0.003 CELO",
|
||||
publicKey: []byte("0xrqeqrequuq"),
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{flag_invalid_amount},
|
||||
Content: "0.02ms",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
@@ -1536,7 +1480,7 @@ func TestValidateAmount(t *testing.T) {
|
||||
|
||||
mockDataStore.On("ReadEntry", ctx, sessionId, utils.DATA_PUBLIC_KEY).Return(tt.publicKey, nil)
|
||||
mockCreateAccountService.On("CheckBalance", string(tt.publicKey)).Return(tt.balance, nil)
|
||||
mockDataStore.On("WriteEntry", ctx, sessionId, utils.DATA_AMOUNT, tt.input).Return(nil)
|
||||
mockDataStore.On("WriteEntry", ctx, sessionId, utils.DATA_AMOUNT, tt.input).Return(nil).Maybe()
|
||||
|
||||
// Call the method under test
|
||||
res, _ := h.ValidateAmount(ctx, "test_validate_amount", tt.input)
|
||||
@@ -1648,6 +1592,7 @@ func TestGetProfile(t *testing.T) {
|
||||
|
||||
mockDataStore := new(mocks.MockUserDataStore)
|
||||
mockCreateAccountService := new(mocks.MockAccountService)
|
||||
|
||||
h := &Handlers{
|
||||
userdataStore: mockDataStore,
|
||||
accountService: mockCreateAccountService,
|
||||
|
||||
11
internal/utils/isocode.go
Normal file
11
internal/utils/isocode.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package utils
|
||||
|
||||
var isoCodes = map[string]bool{
|
||||
"eng": true, // English
|
||||
"swa": true, // Swahili
|
||||
|
||||
}
|
||||
|
||||
func IsValidISO639(code string) bool {
|
||||
return isoCodes[code]
|
||||
}
|
||||
1
services/registration/_catch
Normal file
1
services/registration/_catch
Normal file
@@ -0,0 +1 @@
|
||||
Something went wrong.Please try again
|
||||
1
services/registration/_catch.vis
Normal file
1
services/registration/_catch.vis
Normal file
@@ -0,0 +1 @@
|
||||
HALT
|
||||
@@ -9,4 +9,5 @@ CATCH invalid_amount flag_invalid_amount 1
|
||||
INCMP _ 0
|
||||
LOAD get_recipient 12
|
||||
LOAD get_sender 64
|
||||
LOAD get_amount 12
|
||||
INCMP transaction_pin *
|
||||
|
||||
@@ -11,8 +11,6 @@ MOUT view 7
|
||||
MOUT back 0
|
||||
HALT
|
||||
INCMP my_account 0
|
||||
LOAD set_reset_single_edit 0
|
||||
RELOAD set_reset_single_edit
|
||||
INCMP enter_name 1
|
||||
INCMP enter_familyname 2
|
||||
INCMP select_gender 3
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
CATCH incorrect_pin flag_incorrect_pin 1
|
||||
CATCH profile_update_success flag_allow_update 1
|
||||
LOAD save_gender 0
|
||||
MOUT male 1
|
||||
MOUT female 2
|
||||
MOUT unspecified 3
|
||||
MOUT back 0
|
||||
HALT
|
||||
RELOAD save_gender
|
||||
INCMP _ 0
|
||||
INCMP pin_entry *
|
||||
INCMP set_male 1
|
||||
INCMP set_female 2
|
||||
INCMP set_unspecified 3
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
MOUT english 0
|
||||
MOUT kiswahili 1
|
||||
HALT
|
||||
INCMP set_default 0
|
||||
INCMP set_eng 0
|
||||
INCMP set_swa 1
|
||||
INCMP . *
|
||||
|
||||
4
services/registration/set_female.vis
Normal file
4
services/registration/set_female.vis
Normal file
@@ -0,0 +1,4 @@
|
||||
LOAD save_gender 0
|
||||
CATCH incorrect_pin flag_incorrect_pin 1
|
||||
CATCH profile_update_success flag_allow_update 1
|
||||
MOVE pin_entry
|
||||
4
services/registration/set_male.vis
Normal file
4
services/registration/set_male.vis
Normal file
@@ -0,0 +1,4 @@
|
||||
LOAD save_gender 0
|
||||
CATCH incorrect_pin flag_incorrect_pin 1
|
||||
CATCH profile_update_success flag_allow_update 1
|
||||
MOVE pin_entry
|
||||
4
services/registration/set_unspecified.vis
Normal file
4
services/registration/set_unspecified.vis
Normal file
@@ -0,0 +1,4 @@
|
||||
LOAD save_gender 0
|
||||
CATCH incorrect_pin flag_incorrect_pin 1
|
||||
CATCH profile_update_success flag_allow_update 1
|
||||
MOVE pin_entry
|
||||
@@ -1,7 +1,7 @@
|
||||
LOAD reset_incorrect 6
|
||||
CATCH incorrect_pin flag_incorrect_pin 1
|
||||
CATCH _ flag_account_authorized 0
|
||||
LOAD get_amount 10
|
||||
RELOAD get_amount
|
||||
MAP get_amount
|
||||
RELOAD get_recipient
|
||||
MAP get_recipient
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
{{.get_recipient}} will receive {{.validate_amount}} from {{.get_sender}}
|
||||
{{.get_recipient}} will receive {{.get_amount}} from {{.get_sender}}
|
||||
Please enter your PIN to confirm:
|
||||
@@ -1,12 +1,13 @@
|
||||
MAP validate_amount
|
||||
RELOAD get_amount
|
||||
MAP get_amount
|
||||
RELOAD get_recipient
|
||||
MAP get_recipient
|
||||
RELOAD get_sender
|
||||
MAP get_sender
|
||||
MOUT back 0
|
||||
MOUT quit 9
|
||||
HALT
|
||||
LOAD authorize_account 6
|
||||
HALT
|
||||
RELOAD authorize_account
|
||||
CATCH incorrect_pin flag_incorrect_pin 1
|
||||
INCMP _ 0
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
{{.get_recipient}} atapokea {{.validate_amount}} kutoka kwa {{.get_sender}}
|
||||
{{.get_recipient}} atapokea {{.get_amount}} kutoka kwa {{.get_sender}}
|
||||
Tafadhali weka PIN yako kudhibitisha:
|
||||
Reference in New Issue
Block a user