menu-traversals #108

Closed
carlos wants to merge 72 commits from menu-traversals into master
3 changed files with 13 additions and 11 deletions
Showing only changes of commit 64cc9bc752 - Show all commits

1
go.mod
View File

@ -15,6 +15,7 @@ require (
github.com/barbashov/iso639-3 v0.0.0-20211020172741-1f4ffb2d8d1c // indirect github.com/barbashov/iso639-3 v0.0.0-20211020172741-1f4ffb2d8d1c // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fxamacker/cbor/v2 v2.4.0 // indirect github.com/fxamacker/cbor/v2 v2.4.0 // indirect
github.com/gofrs/uuid v4.4.0+incompatible
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 // indirect github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 // indirect
github.com/hexops/gotextdiff v1.0.3 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a // indirect github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a // indirect

2
go.sum
View File

@ -12,6 +12,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88= github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 h1:U4kkNYryi/qfbBF8gh7Vsbuz+cVmhf5kt6pE9bYYyLo= github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 h1:U4kkNYryi/qfbBF8gh7Vsbuz+cVmhf5kt6pE9bYYyLo=
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4/go.mod h1:zpZDgZFzeq9s0MIeB1P50NIEWDFFHSFBohI/NbaTD/Y= github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4/go.mod h1:zpZDgZFzeq9s0MIeB1P50NIEWDFFHSFBohI/NbaTD/Y=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=

View File

@ -3,8 +3,6 @@ package main
import ( import (
"bytes" "bytes"
"context" "context"
"crypto/rand"
"encoding/hex"
"fmt" "fmt"
"regexp" "regexp"
"testing" "testing"
@ -12,7 +10,7 @@ import (
"git.grassecon.net/urdt/ussd/driver" "git.grassecon.net/urdt/ussd/driver"
enginetest "git.grassecon.net/urdt/ussd/engine" enginetest "git.grassecon.net/urdt/ussd/engine"
"git.grassecon.net/urdt/ussd/internal/utils" "github.com/gofrs/uuid"
) )
var ( var (
@ -20,14 +18,13 @@ var (
sessionID string sessionID string
) )
// GenerateRandomSessionID generates a random session ID of 10 characters // GenerateRandomSessionID generates a random UUID for the sessionID
func GenerateRandomSessionID() string { func GenerateUUID() string {
bytes := make([]byte, 5) u, err := uuid.NewV4()
_, err := rand.Read(bytes)
if err != nil { if err != nil {
return "default_session" return "default_uuid"
} }
return hex.EncodeToString(bytes) return u.String()
} }
// Extract the public key from the engine response // Extract the public key from the engine response
@ -42,7 +39,7 @@ func extractPublicKey(response []byte) string {
} }
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
sessionID = GenerateRandomSessionID() sessionID = GenerateUUID()
m.Run() m.Run()
} }
@ -79,7 +76,9 @@ func TestAccountCreationSuccessful(t *testing.T) {
} }
func TestAccountRegistrationRejectTerms(t *testing.T) { func TestAccountRegistrationRejectTerms(t *testing.T) {
en, fn, _ := enginetest.TestEngine(sessionID + "_b") // Generate a new UUID for this edge case test
edgeCaseSessionID := GenerateUUID()
en, fn, _ := enginetest.TestEngine(edgeCaseSessionID)
defer fn() defer fn()
ctx := context.Background() ctx := context.Background()
sessions := testData sessions := testData