replace Id with ID
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type Customer struct {
|
||||
Id CustomerId
|
||||
ID CustomerID
|
||||
NKodePolicy NKodePolicy
|
||||
Attributes CustomerAttributes
|
||||
}
|
||||
@@ -21,7 +21,7 @@ func NewCustomer(nkodePolicy NKodePolicy) (*Customer, error) {
|
||||
return nil, err
|
||||
}
|
||||
customer := Customer{
|
||||
Id: CustomerId(uuid.New()),
|
||||
ID: CustomerID(uuid.New()),
|
||||
NKodePolicy: nkodePolicy,
|
||||
Attributes: *customerAttrs,
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func (c *Customer) RenewKeys() ([]uint64, []uint64, error) {
|
||||
|
||||
func (c *Customer) ToSqlcCreateCustomerParams() sqlc.CreateCustomerParams {
|
||||
return sqlc.CreateCustomerParams{
|
||||
ID: uuid.UUID(c.Id).String(),
|
||||
ID: uuid.UUID(c.ID).String(),
|
||||
MaxNkodeLen: int64(c.NKodePolicy.MaxNkodeLen),
|
||||
MinNkodeLen: int64(c.NKodePolicy.MinNkodeLen),
|
||||
DistinctSets: int64(c.NKodePolicy.DistinctSets),
|
||||
|
||||
@@ -21,7 +21,7 @@ func testCustomerValidKeyEntry(t *testing.T) {
|
||||
nkodePolicy := NewDefaultNKodePolicy()
|
||||
customer, err := NewCustomer(nkodePolicy)
|
||||
assert.NoError(t, err)
|
||||
mockSvgInterface := make(SvgIdInterface, kp.TotalAttrs())
|
||||
mockSvgInterface := make(SvgIDInterface, kp.TotalAttrs())
|
||||
userInterface, err := NewUserInterface(&kp, mockSvgInterface)
|
||||
assert.NoError(t, err)
|
||||
userEmail := "testing@example.com"
|
||||
@@ -45,7 +45,7 @@ func testCustomerIsValidNKode(t *testing.T) {
|
||||
nkodePolicy := NewDefaultNKodePolicy()
|
||||
customer, err := NewCustomer(nkodePolicy)
|
||||
assert.NoError(t, err)
|
||||
mockSvgInterface := make(SvgIdInterface, kp.TotalAttrs())
|
||||
mockSvgInterface := make(SvgIDInterface, kp.TotalAttrs())
|
||||
userInterface, err := NewUserInterface(&kp, mockSvgInterface)
|
||||
assert.NoError(t, err)
|
||||
userEmail := "testing123@example.com"
|
||||
|
||||
@@ -9,30 +9,30 @@ import (
|
||||
|
||||
type KeySelection []int
|
||||
|
||||
type CustomerId uuid.UUID
|
||||
type CustomerID uuid.UUID
|
||||
|
||||
func (c *CustomerId) String() string {
|
||||
func (c *CustomerID) String() string {
|
||||
id := uuid.UUID(*c)
|
||||
return id.String()
|
||||
}
|
||||
|
||||
type SessionId uuid.UUID
|
||||
type UserId uuid.UUID
|
||||
type SessionID uuid.UUID
|
||||
type UserID uuid.UUID
|
||||
|
||||
func (u *UserId) String() string {
|
||||
func (u *UserID) String() string {
|
||||
id := uuid.UUID(*u)
|
||||
return id.String()
|
||||
}
|
||||
|
||||
func UserIdFromString(userId string) UserId {
|
||||
id, err := uuid.Parse(userId)
|
||||
func UserIDFromString(userID string) UserID {
|
||||
id, err := uuid.Parse(userID)
|
||||
if err != nil {
|
||||
fmt.Errorf("unable to parse user id %+v", err)
|
||||
}
|
||||
return UserId(id)
|
||||
return UserID(id)
|
||||
}
|
||||
|
||||
func (s *SessionId) String() string {
|
||||
func (s *SessionID) String() string {
|
||||
id := uuid.UUID(*s)
|
||||
return id.String()
|
||||
}
|
||||
@@ -49,15 +49,15 @@ func ParseEmail(email string) (UserEmail, error) {
|
||||
}
|
||||
|
||||
type IdxInterface []int
|
||||
type SvgIdInterface []int
|
||||
type SvgIDInterface []int
|
||||
|
||||
func SessionIdFromString(sessionId string) (SessionId, error) {
|
||||
id, err := uuid.Parse(sessionId)
|
||||
func SessionIDFromString(sessionID string) (SessionID, error) {
|
||||
id, err := uuid.Parse(sessionID)
|
||||
if err != nil {
|
||||
return SessionId{}, err
|
||||
return SessionID{}, err
|
||||
}
|
||||
|
||||
return SessionId(id), nil
|
||||
return SessionID(id), nil
|
||||
}
|
||||
|
||||
type EncipheredNKode struct {
|
||||
@@ -91,7 +91,7 @@ var SetColors = []RGBColor{
|
||||
}
|
||||
|
||||
type SignupResetInterface struct {
|
||||
SessionId string `json:"session_id"`
|
||||
SessionID string `json:"session_id"`
|
||||
UserIdxInterface IdxInterface `json:"user_interface"`
|
||||
SvgInterface []string `json:"svg_interface"`
|
||||
Colors []RGBColor `json:"colors"`
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
)
|
||||
|
||||
type User struct {
|
||||
Id UserId
|
||||
CustomerId CustomerId
|
||||
ID UserID
|
||||
CustomerID CustomerID
|
||||
Email UserEmail
|
||||
EncipheredPasscode EncipheredNKode
|
||||
Kp KeypadDimension
|
||||
@@ -130,13 +130,13 @@ func NewUser(customer Customer, userEmail string, passcodeIdx []int, ui UserInte
|
||||
return nil, err
|
||||
}
|
||||
newUser := User{
|
||||
Id: UserId(uuid.New()),
|
||||
ID: UserID(uuid.New()),
|
||||
Email: UserEmail(userEmail),
|
||||
EncipheredPasscode: *encipheredNKode,
|
||||
CipherKeys: *newKeys,
|
||||
Interface: ui,
|
||||
Kp: kp,
|
||||
CustomerId: customer.Id,
|
||||
CustomerID: customer.ID,
|
||||
}
|
||||
return &newUser, nil
|
||||
}
|
||||
|
||||
@@ -9,15 +9,15 @@ import (
|
||||
|
||||
type UserInterface struct {
|
||||
IdxInterface IdxInterface
|
||||
SvgId SvgIdInterface
|
||||
SvgID SvgIDInterface
|
||||
Kp *KeypadDimension
|
||||
}
|
||||
|
||||
func NewUserInterface(kp *KeypadDimension, svgId SvgIdInterface) (*UserInterface, error) {
|
||||
func NewUserInterface(kp *KeypadDimension, svgID SvgIDInterface) (*UserInterface, error) {
|
||||
idxInterface := security.IdentityArray(kp.TotalAttrs())
|
||||
userInterface := UserInterface{
|
||||
IdxInterface: idxInterface,
|
||||
SvgId: svgId,
|
||||
SvgID: svgID,
|
||||
Kp: kp,
|
||||
}
|
||||
if err := userInterface.RandomShuffle(); err != nil {
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
)
|
||||
|
||||
type UserSignSession struct {
|
||||
Id SessionId
|
||||
CustomerId CustomerId
|
||||
ID SessionID
|
||||
CustomerID CustomerID
|
||||
LoginUserInterface UserInterface
|
||||
Kp KeypadDimension
|
||||
SetIdxInterface IdxInterface
|
||||
@@ -24,7 +24,7 @@ type UserSignSession struct {
|
||||
Colors []RGBColor
|
||||
}
|
||||
|
||||
func NewSignupResetSession(userEmail UserEmail, kp KeypadDimension, customerId CustomerId, svgInterface SvgIdInterface, reset bool) (*UserSignSession, error) {
|
||||
func NewSignupResetSession(userEmail UserEmail, kp KeypadDimension, customerId CustomerID, svgInterface SvgIDInterface, reset bool) (*UserSignSession, error) {
|
||||
loginInterface, err := NewUserInterface(&kp, svgInterface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -34,8 +34,8 @@ func NewSignupResetSession(userEmail UserEmail, kp KeypadDimension, customerId C
|
||||
return nil, err
|
||||
}
|
||||
session := UserSignSession{
|
||||
Id: SessionId(uuid.New()),
|
||||
CustomerId: customerId,
|
||||
ID: SessionID(uuid.New()),
|
||||
CustomerID: customerId,
|
||||
LoginUserInterface: *loginInterface,
|
||||
SetIdxInterface: signupInterface.IdxInterface,
|
||||
ConfirmIdxInterface: nil,
|
||||
|
||||
@@ -64,7 +64,7 @@ func TestUserInterface_RandomShuffle(t *testing.T) {
|
||||
AttrsPerKey: 10,
|
||||
NumbOfKeys: 8,
|
||||
}
|
||||
mockSvgInterface := make(SvgIdInterface, kp.TotalAttrs())
|
||||
mockSvgInterface := make(SvgIDInterface, kp.TotalAttrs())
|
||||
userInterface, err := NewUserInterface(&kp, mockSvgInterface)
|
||||
assert.NoError(t, err)
|
||||
userInterfaceCopy := make([]int, len(userInterface.IdxInterface))
|
||||
@@ -87,7 +87,7 @@ func TestUserInterface_DisperseInterface(t *testing.T) {
|
||||
|
||||
for idx := 0; idx < 10000; idx++ {
|
||||
kp := KeypadDimension{AttrsPerKey: 7, NumbOfKeys: 10}
|
||||
mockSvgInterface := make(SvgIdInterface, kp.TotalAttrs())
|
||||
mockSvgInterface := make(SvgIDInterface, kp.TotalAttrs())
|
||||
userInterface, err := NewUserInterface(&kp, mockSvgInterface)
|
||||
assert.NoError(t, err)
|
||||
preDispersion, err := userInterface.AttributeAdjacencyGraph()
|
||||
@@ -106,7 +106,7 @@ func TestUserInterface_DisperseInterface(t *testing.T) {
|
||||
|
||||
func TestUserInterface_PartialInterfaceShuffle(t *testing.T) {
|
||||
kp := KeypadDimension{AttrsPerKey: 7, NumbOfKeys: 10}
|
||||
mockSvgInterface := make(SvgIdInterface, kp.TotalAttrs())
|
||||
mockSvgInterface := make(SvgIDInterface, kp.TotalAttrs())
|
||||
userInterface, err := NewUserInterface(&kp, mockSvgInterface)
|
||||
assert.NoError(t, err)
|
||||
preShuffle := userInterface.IdxInterface
|
||||
|
||||
Reference in New Issue
Block a user