forked from grassrootseconomics/visedriver
		
	Merge remote-tracking branch 'refs/remotes/origin/menu-traversals' into menu-traversals
This commit is contained in:
		
						commit
						64cc9bc752
					
				
							
								
								
									
										1
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								go.mod
									
									
									
									
									
								
							@ -15,6 +15,7 @@ require (
 | 
			
		||||
	github.com/barbashov/iso639-3 v0.0.0-20211020172741-1f4ffb2d8d1c // indirect
 | 
			
		||||
	github.com/davecgh/go-spew v1.1.1 // 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/hexops/gotextdiff v1.0.3 // indirect
 | 
			
		||||
	github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a // indirect
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.sum
									
									
									
									
									
								
							@ -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/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
 | 
			
		||||
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/go.mod h1:zpZDgZFzeq9s0MIeB1P50NIEWDFFHSFBohI/NbaTD/Y=
 | 
			
		||||
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
 | 
			
		||||
 | 
			
		||||
@ -3,8 +3,6 @@ package main
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"context"
 | 
			
		||||
	"crypto/rand"
 | 
			
		||||
	"encoding/hex"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"regexp"
 | 
			
		||||
	"testing"
 | 
			
		||||
@ -12,7 +10,7 @@ import (
 | 
			
		||||
 | 
			
		||||
	"git.grassecon.net/urdt/ussd/driver"
 | 
			
		||||
	enginetest "git.grassecon.net/urdt/ussd/engine"
 | 
			
		||||
	"git.grassecon.net/urdt/ussd/internal/utils"
 | 
			
		||||
	"github.com/gofrs/uuid"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
@ -20,14 +18,13 @@ var (
 | 
			
		||||
	sessionID string
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// GenerateRandomSessionID generates a random session ID of 10 characters
 | 
			
		||||
func GenerateRandomSessionID() string {
 | 
			
		||||
	bytes := make([]byte, 5)
 | 
			
		||||
	_, err := rand.Read(bytes)
 | 
			
		||||
// GenerateRandomSessionID generates a random UUID for the sessionID
 | 
			
		||||
func GenerateUUID() string {
 | 
			
		||||
	u, err := uuid.NewV4()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "default_session"
 | 
			
		||||
		return "default_uuid"
 | 
			
		||||
	}
 | 
			
		||||
	return hex.EncodeToString(bytes)
 | 
			
		||||
	return u.String()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Extract the public key from the engine response
 | 
			
		||||
@ -42,7 +39,7 @@ func extractPublicKey(response []byte) string {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestMain(m *testing.M) {
 | 
			
		||||
	sessionID = GenerateRandomSessionID()
 | 
			
		||||
	sessionID = GenerateUUID()
 | 
			
		||||
	m.Run()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -79,7 +76,9 @@ func TestAccountCreationSuccessful(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()
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	sessions := testData
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user