@@ -314,7 +314,7 @@ func (s *OrgInvitationIntegrationTestSuite) TestInvitationWithGroupContext() {
314314 s .T ().Run ("invitation with group context adds user to group when accepted" , func (t * testing.T ) {
315315 // Create invitation context with group information
316316 invitationContext := & biz.OrgInvitationContext {
317- GroupIDToJoin : group .ID ,
317+ GroupIDToJoin : & group .ID ,
318318 GroupMaintainer : true ,
319319 }
320320
@@ -332,7 +332,7 @@ func (s *OrgInvitationIntegrationTestSuite) TestInvitationWithGroupContext() {
332332
333333 // Verify context was saved properly
334334 assert .NotNil (t , invite .Context )
335- assert .Equal (t , group .ID , invite .Context .GroupIDToJoin )
335+ assert .Equal (t , group .ID , * invite .Context .GroupIDToJoin )
336336 assert .Equal (t , true , invite .Context .GroupMaintainer )
337337
338338 // Accept the invitation
@@ -380,7 +380,7 @@ func (s *OrgInvitationIntegrationTestSuite) TestInvitationWithGroupContext() {
380380
381381 // Create invitation context with group information, but not as maintainer
382382 invitationContext := & biz.OrgInvitationContext {
383- GroupIDToJoin : group .ID ,
383+ GroupIDToJoin : & group .ID ,
384384 GroupMaintainer : false ,
385385 }
386386
@@ -447,7 +447,7 @@ func (s *OrgInvitationIntegrationTestSuite) TestInvitationWithProjectContext() {
447447 s .T ().Run ("invitation with project context adds user to project when accepted" , func (t * testing.T ) {
448448 // Create invitation context with project information
449449 invitationContext := & biz.OrgInvitationContext {
450- ProjectIDToJoin : project .ID ,
450+ ProjectIDToJoin : & project .ID ,
451451 ProjectRole : authz .RoleProjectAdmin ,
452452 }
453453
@@ -465,7 +465,7 @@ func (s *OrgInvitationIntegrationTestSuite) TestInvitationWithProjectContext() {
465465
466466 // Verify context was saved properly
467467 assert .NotNil (t , invite .Context )
468- assert .Equal (t , project .ID , invite .Context .ProjectIDToJoin )
468+ assert .Equal (t , project .ID , * invite .Context .ProjectIDToJoin )
469469 assert .Equal (t , authz .RoleProjectAdmin , invite .Context .ProjectRole )
470470
471471 // Accept the invitation
@@ -511,7 +511,7 @@ func (s *OrgInvitationIntegrationTestSuite) TestInvitationWithProjectContext() {
511511
512512 // Create invitation context with project information, but with viewer role
513513 invitationContext := & biz.OrgInvitationContext {
514- ProjectIDToJoin : project .ID ,
514+ ProjectIDToJoin : & project .ID ,
515515 ProjectRole : authz .RoleProjectViewer ,
516516 }
517517
@@ -570,9 +570,9 @@ func (s *OrgInvitationIntegrationTestSuite) TestInvitationWithProjectContext() {
570570
571571 // Create invitation context with both group and project information
572572 invitationContext := & biz.OrgInvitationContext {
573- GroupIDToJoin : group .ID ,
573+ GroupIDToJoin : & group .ID ,
574574 GroupMaintainer : true ,
575- ProjectIDToJoin : project .ID ,
575+ ProjectIDToJoin : & project .ID ,
576576 ProjectRole : authz .RoleProjectViewer ,
577577 }
578578
@@ -590,9 +590,9 @@ func (s *OrgInvitationIntegrationTestSuite) TestInvitationWithProjectContext() {
590590
591591 // Verify context was saved properly
592592 assert .NotNil (t , invite .Context )
593- assert .Equal (t , group .ID , invite .Context .GroupIDToJoin )
593+ assert .Equal (t , group .ID , * invite .Context .GroupIDToJoin )
594594 assert .True (t , invite .Context .GroupMaintainer )
595- assert .Equal (t , project .ID , invite .Context .ProjectIDToJoin )
595+ assert .Equal (t , project .ID , * invite .Context .ProjectIDToJoin )
596596 assert .Equal (t , authz .RoleProjectViewer , invite .Context .ProjectRole )
597597
598598 // Accept the invitation
@@ -645,6 +645,64 @@ func (s *OrgInvitationIntegrationTestSuite) TestInvitationWithProjectContext() {
645645 assert .True (t , foundProjectMember , "The user should be a member of the project" )
646646 assert .Equal (t , authz .RoleProjectViewer , projectRole , "The user should have the project contributor role" )
647647 })
648+
649+ s .T ().Run ("invitation with nil UUID on project is rejected" , func (t * testing.T ) {
650+ // Create a new receiver that isn't a member of any org yet
651+ newReceiverEmail := "[email protected] " 652+ newReceiver , err := s .User .UpsertByEmail (ctx , newReceiverEmail , nil )
653+ require .NoError (t , err )
654+ require .NotNil (t , newReceiver )
655+
656+ // Create invitation context with nil project ID
657+ invitationContext := & biz.OrgInvitationContext {
658+ ProjectIDToJoin : & uuid .Nil ,
659+ }
660+
661+ // Create invitation with combined context
662+ invite , err := s .Repos .OrgInvitationRepo .Create (
663+ ctx ,
664+ uuid .MustParse (s .org1 .ID ),
665+ uuid .MustParse (s .user .ID ),
666+ newReceiverEmail ,
667+ authz .RoleViewer ,
668+ invitationContext ,
669+ )
670+ require .NoError (t , err )
671+ require .NotNil (t , invite )
672+
673+ // Accept the invitation and check that there is no error
674+ err = s .OrgInvitation .AcceptPendingInvitations (ctx , newReceiverEmail )
675+ require .NoError (t , err , "Accepting invitation with nil project ID should not fail just skip the project context" )
676+ })
677+
678+ s .T ().Run ("invitation with nil UUID on group is rejected" , func (t * testing.T ) {
679+ // Create a new receiver that isn't a member of any org yet
680+ newReceiverEmail := "[email protected] " 681+ newReceiver , err := s .User .UpsertByEmail (ctx , newReceiverEmail , nil )
682+ require .NoError (t , err )
683+ require .NotNil (t , newReceiver )
684+
685+ // Create invitation context with nil group ID
686+ invitationContext := & biz.OrgInvitationContext {
687+ GroupIDToJoin : & uuid .Nil ,
688+ }
689+
690+ // Create invitation with combined context
691+ invite , err := s .Repos .OrgInvitationRepo .Create (
692+ ctx ,
693+ uuid .MustParse (s .org1 .ID ),
694+ uuid .MustParse (s .user .ID ),
695+ newReceiverEmail ,
696+ authz .RoleViewer ,
697+ invitationContext ,
698+ )
699+ require .NoError (t , err )
700+ require .NotNil (t , invite )
701+
702+ // Accept the invitation and check that there is no error
703+ err = s .OrgInvitation .AcceptPendingInvitations (ctx , newReceiverEmail )
704+ require .NoError (t , err , "Accepting invitation with nil group ID should not fail just skip the project context" )
705+ })
648706}
649707
650708// Utility struct to hold the test suite
0 commit comments