@@ -110,6 +110,14 @@ func (suite *HandlerTestSuite) TestLoginHandler() {
110110 confirmedUser : true ,
111111 tfaEnabled : tfaTrue ,
112112 })
113+
114+ auditorUser := suite .userBuilderWithInput (ctx , & userInput {
115+ email : "auditor+" + strings .ToLower (ulids .New ().String ()) + "@examples.com" ,
116+ password : validPassword ,
117+ confirmedUser : true ,
118+ tfaEnabled : tfaTrue ,
119+ })
120+
113121 // setup allow context with the client in the context which is required for hooks that run
114122 allowCtx := privacy .DecisionContext (validConfirmedUserRestrictedOrg .UserCtx , privacy .Allow )
115123 allowCtx = ent .NewContext (allowCtx , suite .db )
@@ -121,6 +129,10 @@ func (suite *HandlerTestSuite) TestLoginHandler() {
121129 ctxTargetOrg = privacy .DecisionContext (ctxTargetOrg , privacy .Allow )
122130 testUserCtx := ent .NewContext (ctxTargetOrg , suite .db )
123131
132+ auditorOrgCtx := auth .NewTestContextWithOrgID (validConfirmedUserRestrictedOrg .ID , org .ID )
133+ auditorOrgCtx = privacy .DecisionContext (auditorOrgCtx , privacy .Allow )
134+ auditorOrgCtx = ent .NewContext (auditorOrgCtx , suite .db )
135+
124136 suite .db .OrgMembership .Create ().SetInput (generated.CreateOrgMembershipInput {
125137 OrganizationID : createdssoOrg .ID ,
126138 UserID : ssoMember .UserInfo .ID ,
@@ -129,6 +141,14 @@ func (suite *HandlerTestSuite) TestLoginHandler() {
129141
130142 suite .db .UserSetting .UpdateOneID (ssoMember .UserInfo .Edges .Setting .ID ).SetDefaultOrgID (createdssoOrg .ID ).ExecX (allowCtx )
131143
144+ suite .db .OrgMembership .Create ().SetInput (generated.CreateOrgMembershipInput {
145+ OrganizationID : org .ID ,
146+ UserID : auditorUser .UserInfo .ID ,
147+ Role : & enums .RoleAuditor ,
148+ }).ExecX (auditorOrgCtx )
149+
150+ suite .db .UserSetting .UpdateOneID (auditorUser .UserInfo .Edges .Setting .ID ).SetDefaultOrgID (org .ID ).ExecX (allowCtx )
151+
132152 // update the user settings to have the default org set that is the domain restricted org
133153 suite .db .UserSetting .UpdateOneID (validConfirmedUserRestrictedOrg .UserInfo .Edges .Setting .ID ).
134154 SetDefaultOrgID (org .ID ).ExecX (allowCtx )
@@ -176,6 +196,18 @@ func (suite *HandlerTestSuite) TestLoginHandler() {
176196 models .CatalogTrustCenterModule .String (),
177197 },
178198 },
199+ {
200+ name : "happy path, auditor default org" ,
201+ username : auditorUser .UserInfo .Email ,
202+ password : validPassword ,
203+ expectedStatus : http .StatusOK ,
204+ expectedOrgID : org .ID ,
205+ expectedModules : []interface {}{
206+ models .CatalogBaseModule .String (),
207+ models .CatalogComplianceModule .String (),
208+ models .CatalogTrustCenterModule .String (),
209+ },
210+ },
179211 {
180212 name : "domain restricted org, email not allowed, switch to personal org" ,
181213 username : invalidConfirmedUserRestrictedOrg .UserInfo .Email ,
0 commit comments