Skip to content
Snippets Groups Projects
Commit c7cf597b authored by Josh Brooks's avatar Josh Brooks
Browse files

Fix pipeline

parent 5cfc066e
No related branches found
No related tags found
2 merge requests!58Draft: Projects/crust RELEASE,!55Add validateUsername endpoint to UD
......@@ -10,11 +10,11 @@ require (
github.com/spf13/viper v1.11.0
github.com/ttacon/libphonenumber v1.2.1
gitlab.com/elixxir/client v1.5.1-0.20220725172207-3ef87e8c794c
gitlab.com/elixxir/comms v0.0.4-0.20220819183938-d6cd8aca6de4
gitlab.com/elixxir/comms v0.0.4-0.20220819220424-f2328c8b26b1
gitlab.com/elixxir/crypto v0.0.7-0.20220818194137-973a70947df4
gitlab.com/elixxir/primitives v0.0.3-0.20220606195757-40f7a589347f
gitlab.com/elixxir/primitives v0.0.3-0.20220810173935-592f34a88326
gitlab.com/xx_network/comms v0.0.4-0.20220630163702-f3d372ef6acd
gitlab.com/xx_network/crypto v0.0.5-0.20220606200528-3f886fe49e81
gitlab.com/xx_network/crypto v0.0.5-0.20220729193517-1e5e96f39f6e
gitlab.com/xx_network/primitives v0.0.4-0.20220712193914-aebd8544396e
gorm.io/driver/postgres v1.1.2
gorm.io/gorm v1.21.15
......
......@@ -566,6 +566,8 @@ gitlab.com/elixxir/comms v0.0.4-0.20220819183658-b42c691e54e4 h1:SQ+RGR8mPBlef8G
gitlab.com/elixxir/comms v0.0.4-0.20220819183658-b42c691e54e4/go.mod h1:tlHSrtSliKWUxsck8z/Ql/VJkMdSONV2BeWaUAAXzgk=
gitlab.com/elixxir/comms v0.0.4-0.20220819183938-d6cd8aca6de4 h1:CgI8Xb9lXxeJaMs88cksR2wc30WBR6BVlq2alY1QklY=
gitlab.com/elixxir/comms v0.0.4-0.20220819183938-d6cd8aca6de4/go.mod h1:tlHSrtSliKWUxsck8z/Ql/VJkMdSONV2BeWaUAAXzgk=
gitlab.com/elixxir/comms v0.0.4-0.20220819220424-f2328c8b26b1 h1:KZ8wKOenvQaYNKo+4jdVhy3YJ7Xa3obiPxGziGJWUb4=
gitlab.com/elixxir/comms v0.0.4-0.20220819220424-f2328c8b26b1/go.mod h1:j6so9oYAj2YRjOOu11gFBldtxy4ez/oPkYfqM2J1q1k=
gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c=
gitlab.com/elixxir/crypto v0.0.3/go.mod h1:ZNgBOblhYToR4m8tj4cMvJ9UsJAUKq+p0gCp07WQmhA=
gitlab.com/elixxir/crypto v0.0.7-0.20220317172048-3de167bd9406/go.mod h1:tD6XjtQh87T2nKZL5I/pYPck5M2wLpkZ1Oz7H/LqO10=
......@@ -583,6 +585,8 @@ gitlab.com/elixxir/primitives v0.0.3-0.20220222212109-d412a6e46623/go.mod h1:MtF
gitlab.com/elixxir/primitives v0.0.3-0.20220323183834-b98f255361b8/go.mod h1:MtFIyJUQn9P7djzVlBpEYkPNnnWFTjZvw89swoXY+QM=
gitlab.com/elixxir/primitives v0.0.3-0.20220606195757-40f7a589347f h1:CTf2+ewHWYrzp5Ar3RwNvHePfTHyFniJTVjFW4zqoaE=
gitlab.com/elixxir/primitives v0.0.3-0.20220606195757-40f7a589347f/go.mod h1:9Bb2+u+CDSwsEU5Droo6saDAXuBDvLRjexpBhPAYxhA=
gitlab.com/elixxir/primitives v0.0.3-0.20220810173935-592f34a88326 h1:NrgEawIlebJXvIJXvw0wJOGMfOogb1HlcqbpucYteJY=
gitlab.com/elixxir/primitives v0.0.3-0.20220810173935-592f34a88326/go.mod h1:9Bb2+u+CDSwsEU5Droo6saDAXuBDvLRjexpBhPAYxhA=
gitlab.com/xx_network/comms v0.0.0-20200805174823-841427dd5023/go.mod h1:owEcxTRl7gsoM8c3RQ5KAm5GstxrJp5tn+6JfQ4z5Hw=
gitlab.com/xx_network/comms v0.0.4-0.20220315161313-76acb14429ac h1:+ykw0JqLH/qMprPEKazGHNH8gUoHGA78EIr4ienxnw4=
gitlab.com/xx_network/comms v0.0.4-0.20220315161313-76acb14429ac/go.mod h1:isHnwem0v4rTcwwHP455FhVlFyPcHkHiVz+N3s/uCSI=
......@@ -594,6 +598,8 @@ gitlab.com/xx_network/crypto v0.0.5-0.20220222212031-750f7e8a01f4/go.mod h1:6apv
gitlab.com/xx_network/crypto v0.0.5-0.20220317171841-084640957d71/go.mod h1:/SJf+R75E+QepdTLh0H1/udsovxx2Q5ru34q1v0umKk=
gitlab.com/xx_network/crypto v0.0.5-0.20220606200528-3f886fe49e81 h1:9HK48ZEGFKLm3HBcE/FdQitllJRYPPS0zeaiRL+MBhI=
gitlab.com/xx_network/crypto v0.0.5-0.20220606200528-3f886fe49e81/go.mod h1:/SJf+R75E+QepdTLh0H1/udsovxx2Q5ru34q1v0umKk=
gitlab.com/xx_network/crypto v0.0.5-0.20220729193517-1e5e96f39f6e h1:k+M0zo9eyL2mGaduggdQnwxzOIqOIBV9WIt1QCq92sA=
gitlab.com/xx_network/crypto v0.0.5-0.20220729193517-1e5e96f39f6e/go.mod h1:/SJf+R75E+QepdTLh0H1/udsovxx2Q5ru34q1v0umKk=
gitlab.com/xx_network/primitives v0.0.0-20200803231956-9b192c57ea7c/go.mod h1:wtdCMr7DPePz9qwctNoAUzZtbOSHSedcK++3Df3psjA=
gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da/go.mod h1:OK9xevzWCaPO7b1wiluVJGk7R5ZsuC7pHY5hteZFQug=
gitlab.com/xx_network/primitives v0.0.2/go.mod h1:cs0QlFpdMDI6lAo61lDRH2JZz+3aVkHy+QogOB6F/qc=
......
......@@ -18,6 +18,7 @@ import (
"time"
)
// Happy path.
func TestValidateUsername(t *testing.T) {
// Initialize fields needed for testing
clientId, rsaPrivKey := initClientFields(t)
......@@ -63,9 +64,58 @@ func TestValidateUsername(t *testing.T) {
t.Fatalf("Failed to validate username: %+v", err)
}
err = crust.VerifyVerificationSignature(rsaPrivKey.GetPublic(), username, pubKeyPem, validationResponse.Signature)
err = crust.VerifyVerificationSignature(rsaPrivKey.GetPublic(),
username, pubKeyPem, validationResponse.Signature)
if err != nil {
t.Fatalf("validateUsername did not return a valid signature!")
}
}
// Error path: Try to validate a username that does not belong to the user.
func TestValidateUsername_UsernameMismatch(t *testing.T) {
// Initialize fields needed for testing
clientId, rsaPrivKey := initClientFields(t)
store := storage.NewTestDB(t)
ndfObj, _ := ndf.Unmarshal(getNDF())
cert, err := loadPermissioningPubKey(ndfObj.Registration.TlsCertificate)
if err != nil {
t.Errorf(err.Error())
}
// Register user first -------------------------------------------------------------------------
testTime, err := time.Parse(time.RFC3339,
"2012-12-21T22:08:41+00:00")
if err != nil {
t.Fatalf("Could not parse precanned time: %v", err.Error())
}
registerMsg, err := buildUserRegistrationMessage(clientId, rsaPrivKey, testTime, t)
if err != nil {
t.Fatalf("Failed to build registration message: %+v", err)
}
bannedManager, err := banned.NewManager("", "")
if err != nil {
t.Fatalf("Failed to construct ban manager: %v", err)
}
_, err = registerUser(registerMsg, cert, store, bannedManager, false)
if err != nil {
t.Errorf("Failed happy path: %v", err)
}
// Test Validate username ----------------------------------------------------------------------
pubKeyPem := []byte(registerMsg.RSAPublicPem)
validationRequest := &pb.UsernameValidationRequest{
Username: "admin",
ReceptionPublicKeyPem: pubKeyPem,
UserId: registerMsg.UID,
}
// Send a validation request using a username that does not belong to this user
_, err = validateUsername(validationRequest, store, rsaPrivKey, rand.Reader)
if err != nil { // This should return an error
t.Fatalf("Failed to validate username: %+v", err)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment