This repository has been archived by the owner on May 7, 2024. It is now read-only.
forked from transcom/mymove
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb2152d
commit 0ccdad1
Showing
22 changed files
with
218 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
alter table users | ||
add column okta_email text, | ||
add column okta_uuid UUID; | ||
add column okta_id varchar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,13 +94,13 @@ func (suite *FactorySuite) TestMergeCustomization() { | |
// Under test: mergeCustomization, which merges traits and customizations | ||
// Set up: Create a customization with a user email and a trait with a user email | ||
// Expected outcome: Customization should override the trait email | ||
uuidval := uuid.Must(uuid.NewV4()) | ||
uuidvalString := uuid.Must(uuid.NewV4()).String() | ||
// RUN FUNCTION UNDER TEST | ||
result := mergeCustomization( | ||
[]Customization{ | ||
{ | ||
Model: models.User{ | ||
OktaUUID: &uuidval, | ||
OktaID: uuidvalString, | ||
OktaEmail: "[email protected]", | ||
}, | ||
Type: &User, // ← User customization | ||
|
@@ -187,10 +187,10 @@ func (suite *FactorySuite) TestMergeInterfaces() { | |
OktaEmail: "[email protected]", | ||
Active: true, | ||
} | ||
uuidNew := uuid.Must(uuid.NewV4()) | ||
uuidNew := uuid.Must(uuid.NewV4()).String() | ||
user2 := models.User{ | ||
OktaEmail: "[email protected]", | ||
OktaUUID: &uuidNew, | ||
OktaID: uuidNew, | ||
} | ||
|
||
result := mergeInterfaces(user2, user1) | ||
|
@@ -199,7 +199,7 @@ func (suite *FactorySuite) TestMergeInterfaces() { | |
suite.Equal(user1.OktaEmail, user.OktaEmail) | ||
// All other fields set in interfaces should persist | ||
suite.Equal(user1.Active, user.Active) | ||
suite.Equal(user2.OktaUUID, user.OktaUUID) | ||
suite.Equal(user2.OktaID, user.OktaID) | ||
}) | ||
|
||
suite.Run("Check that mergeInterfaces doesn't change input models", func() { | ||
|
@@ -208,15 +208,15 @@ func (suite *FactorySuite) TestMergeInterfaces() { | |
// Expected outcome: Caller models should not be affected | ||
user1email := "[email protected]" | ||
user2email := "[email protected]" | ||
uuidNew := uuid.Must(uuid.NewV4()) | ||
uuidNew := uuid.Must(uuid.NewV4()).String() | ||
|
||
user1 := models.User{ | ||
OktaEmail: user1email, | ||
Active: true, | ||
} | ||
user2 := models.User{ | ||
OktaEmail: user2email, | ||
OktaUUID: &uuidNew, | ||
OktaID: uuidNew, | ||
} | ||
|
||
mergeInterfaces(user2, user1) | ||
|
@@ -228,7 +228,7 @@ func (suite *FactorySuite) TestMergeInterfaces() { | |
// user2 should be untouched | ||
suite.Equal(user2email, user2.OktaEmail) | ||
suite.False(user2.Active) | ||
suite.Equal(uuidNew, *user2.OktaUUID) | ||
suite.Equal(uuidNew, user2.OktaID) | ||
}) | ||
} | ||
|
||
|
@@ -455,12 +455,12 @@ func (suite *FactorySuite) TestSetupCustomizations() { | |
// Set up: Create a customization with a user email and a trait with a user email | ||
// Expected outcome: Customization should override the trait email | ||
// If an object exists and no customization, it should become a customization | ||
uuidval := uuid.Must(uuid.NewV4()) | ||
uuidval := uuid.Must(uuid.NewV4()).String() | ||
result := setupCustomizations( | ||
[]Customization{ | ||
{ | ||
Model: models.User{ | ||
OktaUUID: &uuidval, | ||
OktaID: uuidval, | ||
OktaEmail: "[email protected]", | ||
}, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,9 +30,9 @@ func BuildUser(db *pop.Connection, customs []Customization, traits []Trait) mode | |
} | ||
|
||
// create user | ||
oktaUUID := uuid.Must(uuid.NewV4()) | ||
OktaID := uuid.Must(uuid.NewV4()).String() | ||
user := models.User{ | ||
OktaUUID: &oktaUUID, | ||
OktaID: OktaID, | ||
OktaEmail: "[email protected]", | ||
Active: false, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,10 +114,10 @@ func (suite *AuthSuite) TestGenerateNonce() { | |
} | ||
|
||
func (suite *AuthSuite) TestAuthorizationLogoutHandler() { | ||
oktaUUID, _ := uuid.FromString("2400c3c5-019d-4031-9c27-8a553e022297") | ||
OktaID := "2400c3c5-019d-4031-9c27-8a553e022297" | ||
|
||
user := models.User{ | ||
OktaUUID: &oktaUUID, | ||
OktaID: OktaID, | ||
OktaEmail: "[email protected]", | ||
Active: true, | ||
} | ||
|
@@ -183,9 +183,9 @@ func (suite *AuthSuite) TestAuthorizationLogoutHandler() { | |
|
||
func (suite *AuthSuite) TestRequireAuthMiddleware() { | ||
// Given: a logged in user | ||
oktaUUID, _ := uuid.FromString("2400c3c5-019d-4031-9c27-8a553e022297") | ||
OktaID := ("2400c3c5-019d-4031-9c27-8a553e022297") | ||
user := models.User{ | ||
OktaUUID: &oktaUUID, | ||
OktaID: OktaID, | ||
OktaEmail: "[email protected]", | ||
Active: true, | ||
} | ||
|
@@ -341,7 +341,7 @@ func (suite *AuthSuite) TestRequirePermissionsMiddlewareAuthorized() { | |
// TOO users have the proper permissions for our test - update.shipment | ||
tooOfficeUser := factory.BuildOfficeUserWithRoles(suite.DB(), nil, []roles.RoleType{roles.RoleTypeTOO}) | ||
|
||
identity, err := models.FetchUserIdentity(suite.DB(), tooOfficeUser.User.OktaUUID.String()) | ||
identity, err := models.FetchUserIdentity(suite.DB(), tooOfficeUser.User.OktaID) | ||
|
||
suite.NoError(err) | ||
|
||
|
@@ -383,7 +383,7 @@ func (suite *AuthSuite) TestRequirePermissionsMiddlewareUnauthorized() { | |
// QAECSR users will be denied access as they lack the proper permissions for our test - update.shipment | ||
qaeCsrOfficeUser := factory.BuildOfficeUserWithRoles(suite.DB(), nil, []roles.RoleType{roles.RoleTypeQaeCsr}) | ||
|
||
identity, err := models.FetchUserIdentity(suite.DB(), qaeCsrOfficeUser.User.OktaUUID.String()) | ||
identity, err := models.FetchUserIdentity(suite.DB(), qaeCsrOfficeUser.User.OktaID) | ||
|
||
suite.NoError(err) | ||
|
||
|
@@ -437,9 +437,9 @@ func (suite *AuthSuite) TestIsLoggedInWhenNoUserLoggedIn() { | |
} | ||
|
||
func (suite *AuthSuite) TestIsLoggedInWhenUserLoggedIn() { | ||
oktaUUID, _ := uuid.FromString("2400c3c5-019d-4031-9c27-8a553e022297") | ||
OktaID := "2400c3c5-019d-4031-9c27-8a553e022297" | ||
user := models.User{ | ||
OktaUUID: &oktaUUID, | ||
OktaID: OktaID, | ||
OktaEmail: "[email protected]", | ||
Active: true, | ||
} | ||
|
@@ -487,9 +487,9 @@ func (suite *AuthSuite) TestRequireAuthMiddlewareUnauthorized() { | |
|
||
func (suite *AuthSuite) TestRequireAdminAuthMiddleware() { | ||
// Given: a logged in user | ||
oktaUUID, _ := uuid.FromString("2400c3c5-019d-4031-9c27-8a553e022297") | ||
OktaID := "2400c3c5-019d-4031-9c27-8a553e022297" | ||
user := models.User{ | ||
OktaUUID: &oktaUUID, | ||
OktaID: OktaID, | ||
OktaEmail: "[email protected]", | ||
Active: true, | ||
} | ||
|
@@ -563,7 +563,7 @@ func (suite *AuthSuite) TestAuthKnownSingleRoleOffice() { | |
officeUser := factory.BuildOfficeUserWithRoles(suite.DB(), factory.GetTraitActiveOfficeUser(), | ||
[]roles.RoleType{roles.RoleTypeTIO}) | ||
|
||
userIdentity, err := models.FetchUserIdentity(suite.DB(), officeUser.User.OktaUUID.String()) | ||
userIdentity, err := models.FetchUserIdentity(suite.DB(), officeUser.User.OktaID) | ||
suite.Assert().NoError(err) | ||
|
||
handlerConfig := suite.HandlerConfig() | ||
|
@@ -623,10 +623,10 @@ func (suite *AuthSuite) TestAuthorizeDeactivateOfficeUser() { | |
|
||
func (suite *AuthSuite) TestRedirectoktaErrorMsg() { | ||
officeUserID := uuid.Must(uuid.NewV4()) | ||
oktaUUID, _ := uuid.FromString("2400c3c5-019d-4031-9c27-8a553e022297") | ||
OktaID := ("2400c3c5-019d-4031-9c27-8a553e022297") | ||
|
||
user := models.User{ | ||
OktaUUID: &oktaUUID, | ||
OktaID: OktaID, | ||
OktaEmail: "[email protected]", | ||
Active: true, | ||
} | ||
|
@@ -786,7 +786,7 @@ func (suite *AuthSuite) TestRedirectFromoktaForValidUser() { | |
StubName: officeProviderName, | ||
StubToken: "stubToken", | ||
StubUser: goth.User{ | ||
UserID: tioOfficeUser.User.OktaUUID.String(), | ||
UserID: tioOfficeUser.User.OktaID, | ||
Email: tioOfficeUser.Email, | ||
}, | ||
} | ||
|
@@ -846,7 +846,7 @@ func (suite *AuthSuite) TestRedirectFromLoginGovForInvalidUser() { | |
StubName: officeProviderName, | ||
StubToken: "stubToken", | ||
StubUser: goth.User{ | ||
UserID: tioOfficeUser.User.OktaUUID.String(), | ||
UserID: tioOfficeUser.User.OktaID, | ||
Email: tioOfficeUser.Email, | ||
}, | ||
} | ||
|
@@ -872,10 +872,10 @@ func (suite *AuthSuite) TestAuthKnownSingleRoleAdmin() { | |
adminUserID := uuid.Must(uuid.NewV4()) | ||
officeUserID := uuid.Must(uuid.NewV4()) | ||
var adminUserRole models.AdminRole = "SYSTEM_ADMIN" | ||
oktaUUID, _ := uuid.FromString("2400c3c5-019d-4031-9c27-8a553e022297") | ||
OktaID := ("2400c3c5-019d-4031-9c27-8a553e022297") | ||
|
||
user := models.User{ | ||
OktaUUID: &oktaUUID, | ||
OktaID: OktaID, | ||
OktaEmail: "[email protected]", | ||
Active: true, | ||
} | ||
|
@@ -1017,9 +1017,9 @@ func (suite *AuthSuite) TestAuthUnknownServiceMember() { | |
// Verify session contains UserID that points to the newly-created user | ||
suite.Equal(foundUser.ID, session.UserID) | ||
|
||
// Verify user's OktaEmail and OktaUUID match the values passed in | ||
// Verify user's OktaEmail and OktaID match the values passed in | ||
suite.Equal(user.Email, foundUser.OktaEmail) | ||
suite.Equal(user.UserID, foundUser.OktaUUID.String()) | ||
suite.Equal(user.UserID, foundUser.OktaID) | ||
|
||
// Verify that the user's CurrentMilSessionID is not empty. The value is | ||
// generated randomly, so we can't test for a specific string. Any string | ||
|
@@ -1319,12 +1319,12 @@ func (suite *AuthSuite) TestAuthorizeKnownUserAdminNotFound() { | |
appnames := handlerConfig.AppNames() | ||
// user exists in the DB, but not as an admin user | ||
fakeToken := "some_token" | ||
oktaUUID := uuid.Must(uuid.NewV4()) | ||
OktaID := "000" | ||
userID := uuid.Must(uuid.NewV4()) | ||
serviceMemberID := uuid.Must(uuid.NewV4()) | ||
|
||
user := models.User{ | ||
OktaUUID: &oktaUUID, | ||
OktaID: OktaID, | ||
OktaEmail: "[email protected]", | ||
Active: true, | ||
ID: userID, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,9 @@ func (suite *HandlerSuite) TestSearchDutyLocationHandler() { | |
t := suite.T() | ||
|
||
// Need a logged in user | ||
lgu := uuid.Must(uuid.NewV4()) | ||
lgu := uuid.Must(uuid.NewV4()).String() | ||
user := models.User{ | ||
OktaUUID: &lgu, | ||
OktaID: lgu, | ||
OktaEmail: "[email protected]", | ||
} | ||
suite.MustSave(&user) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ import ( | |
"time" | ||
|
||
"github.com/go-openapi/strfmt" | ||
"github.com/gofrs/uuid" | ||
|
||
"github.com/transcom/mymove/pkg/factory" | ||
certop "github.com/transcom/mymove/pkg/gen/internalapi/internaloperations/certification" | ||
|
@@ -65,9 +64,9 @@ func (suite *HandlerSuite) TestCreateSignedCertificationHandler() { | |
func (suite *HandlerSuite) TestCreateSignedCertificationHandlerMismatchedUser() { | ||
t := suite.T() | ||
|
||
userUUID2, _ := uuid.FromString("3511d4d6-019d-4031-9c27-8a553e055543") | ||
userUUID2 := "3511d4d6-019d-4031-9c27-8a553e055543" | ||
user2 := models.User{ | ||
OktaUUID: &userUUID2, | ||
OktaID: userUUID2, | ||
OktaEmail: "[email protected]", | ||
} | ||
suite.MustSave(&user2) | ||
|
@@ -194,9 +193,9 @@ func (suite *HandlerSuite) TestIndexSignedCertificationHandlerMismatchedUser() { | |
}, | ||
}, | ||
}, nil) | ||
userUUID2, _ := uuid.FromString("3511d4d6-019d-4031-9c27-8a553e055543") | ||
userUUID2 := "3511d4d6-019d-4031-9c27-8a553e055543" | ||
unauthorizedUser := models.User{ | ||
OktaUUID: &userUUID2, | ||
OktaID: userUUID2, | ||
OktaEmail: "[email protected]", | ||
} | ||
params := certop.IndexSignedCertificationParams{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,7 +189,7 @@ func (suite *MigrateSuite) TestSplitStatementsCopyFromStdinTrailingEmptyColumns( | |
// We're using a string for this test case instead of a file so the trailing whitespace doesn't accidentally get trimmed off by | ||
// an aggressive text editor. | ||
originalStatements := []string{ | ||
"COPY public.users (id, okta_uuid, okta_email, created_at, updated_at, active, current_mil_session_id, current_admin_session_id, current_office_session_id) FROM stdin;", | ||
"COPY public.users (id, okta_id, okta_email, created_at, updated_at, active, current_mil_session_id, current_admin_session_id, current_office_session_id) FROM stdin;", | ||
"00000000-0000-0000-0000-000000000000\t\\N\t[email protected]\t2021-05-12\t20:09:04.701587\t2021-05-12\t20:09:04.701587\tt\t\t\t", | ||
"11111111-1111-1111-1111-111111111111\t\\N\t[email protected]\t2021-05-12\t20:09:04.701587\t2021-05-12\t20:09:04.701587\tt\t\t\t", | ||
"\\.", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,10 @@ import ( | |
) | ||
|
||
func (suite *ModelSuite) Test_FetchClientCert() { | ||
loginGovUUID := uuid.Must(uuid.NewV4()) | ||
oktaID := uuid.Must(uuid.NewV4()).String() | ||
userForClientCert := models.User{ | ||
ID: uuid.Must(uuid.NewV4()), | ||
OktaUUID: &loginGovUUID, | ||
OktaID: oktaID, | ||
OktaEmail: "[email protected]", | ||
Active: true, | ||
} | ||
|
Oops, something went wrong.