@@ -540,78 +540,6 @@ describe('delete', () => {
540540 ] ) ,
541541 ) ;
542542 } ) ;
543-
544- test . concurrent (
545- 'success: upon integration deletion oidc members are also deleted' ,
546- async ( { expect } ) => {
547- const seed = initSeed ( ) ;
548- const { ownerToken, createOrg } = await seed . createOwner ( ) ;
549- const { organization } = await createOrg ( ) ;
550-
551- const createResult = await execute ( {
552- document : CreateOIDCIntegrationMutation ,
553- variables : {
554- input : {
555- organizationId : organization . id ,
556- clientId : 'foo' ,
557- clientSecret : 'foofoofoofoo' ,
558- tokenEndpoint : 'http://localhost:8888/oauth/token' ,
559- userinfoEndpoint : 'http://localhost:8888/oauth/userinfo' ,
560- authorizationEndpoint : 'http://localhost:8888/oauth/authorize' ,
561- } ,
562- } ,
563- authToken : ownerToken ,
564- } ) . then ( r => r . expectNoGraphQLErrors ( ) ) ;
565-
566- const oidcIntegrationId = createResult . createOIDCIntegration . ok ! . createdOIDCIntegration . id ;
567-
568- const MeQuery = graphql ( `
569- query Me {
570- me {
571- id
572- }
573- }
574- ` ) ;
575-
576- const { access_token : memberAccessToken } = await seed . authenticate (
577- seed . generateEmail ( ) ,
578- oidcIntegrationId ,
579- ) ;
580- const meResult = await execute ( {
581- document : MeQuery ,
582- authToken : memberAccessToken ,
583- } ) . then ( r => r . expectNoGraphQLErrors ( ) ) ;
584-
585- expect ( meResult ) . toEqual ( {
586- me : {
587- id : expect . any ( String ) ,
588- } ,
589- } ) ;
590-
591- await execute ( {
592- document : DeleteOIDCIntegrationMutation ,
593- variables : {
594- input : {
595- oidcIntegrationId,
596- } ,
597- } ,
598- authToken : ownerToken ,
599- } ) . then ( r => r . expectNoGraphQLErrors ( ) ) ;
600-
601- const refetchedMeResult = await execute ( {
602- document : MeQuery ,
603- authToken : memberAccessToken ,
604- } ) . then ( r => r . expectGraphQLErrors ( ) ) ;
605-
606- expect ( refetchedMeResult ) . toEqual (
607- expect . arrayContaining ( [
608- expect . objectContaining ( {
609- message : `No access (reason: "User not found")` ,
610- } ) ,
611- ] ) ,
612- ) ;
613- } ,
614- ) ;
615543 } ) ;
616544} ) ;
617545
@@ -777,45 +705,50 @@ describe('restrictions', () => {
777705 return result . createOIDCIntegration . ok ! . createdOIDCIntegration . id ;
778706 }
779707
780- test . concurrent ( 'non-oidc users cannot join an organization (default)' , async ( { expect } ) => {
781- const seed = initSeed ( ) ;
782- const { ownerToken, createOrg } = await seed . createOwner ( ) ;
783- const { organization, inviteMember, joinMemberUsingCode } = await createOrg ( ) ;
708+ test . concurrent (
709+ 'users authorized with non-OIDC method cannot join an organization (default)' ,
710+ async ( { expect } ) => {
711+ const seed = initSeed ( ) ;
712+ const { ownerToken, createOrg } = await seed . createOwner ( ) ;
713+ const { organization, inviteMember, joinMemberUsingCode } = await createOrg ( ) ;
784714
785- await configureOIDC ( {
786- ownerToken,
787- organizationId : organization . id ,
788- } ) ;
715+ await configureOIDC ( {
716+ ownerToken,
717+ organizationId : organization . id ,
718+ } ) ;
789719
790- const refetchedOrg = await execute ( {
791- document : OrganizationWithOIDCIntegration ,
792- variables : {
793- organizationSlug : organization . slug ,
794- } ,
795- authToken : ownerToken ,
796- } ) . then ( r => r . expectNoGraphQLErrors ( ) ) ;
720+ const refetchedOrg = await execute ( {
721+ document : OrganizationWithOIDCIntegration ,
722+ variables : {
723+ organizationSlug : organization . slug ,
724+ } ,
725+ authToken : ownerToken ,
726+ } ) . then ( r => r . expectNoGraphQLErrors ( ) ) ;
797727
798- expect ( refetchedOrg . organization ?. oidcIntegration ?. oidcUserAccessOnly ) . toEqual ( true ) ;
728+ expect ( refetchedOrg . organization ?. oidcIntegration ?. oidcUserAccessOnly ) . toEqual ( true ) ;
799729
800- const invitation = await inviteMember ( 'example@example.com' ) ;
801- const invitationCode = invitation . ok ?. createdOrganizationInvitation . code ;
730+ const invitation = await inviteMember ( 'example@example.com' ) ;
731+ const invitationCode = invitation . ok ?. createdOrganizationInvitation . code ;
802732
803- if ( ! invitationCode ) {
804- throw new Error ( 'No invitation code' ) ;
805- }
733+ if ( ! invitationCode ) {
734+ throw new Error ( 'No invitation code' ) ;
735+ }
806736
807- const nonOidcAccount = await seed . authenticate ( userEmail ( 'non-oidc-user' ) ) ;
808- const joinResult = await joinMemberUsingCode ( invitationCode , nonOidcAccount . access_token ) . then (
809- r => r . expectNoGraphQLErrors ( ) ,
810- ) ;
737+ const nonOidcAccount = await seed . authenticate ( userEmail ( 'non-oidc-user' ) ) ;
738+ const joinResult = await joinMemberUsingCode (
739+ invitationCode ,
740+ nonOidcAccount . access_token ,
741+ ) . then ( r => r . expectNoGraphQLErrors ( ) ) ;
811742
812- expect ( joinResult . joinOrganization ) . toEqual (
813- expect . objectContaining ( {
814- __typename : 'OrganizationInvitationError' ,
815- message : 'Non-OIDC users are not allowed to join this organization.' ,
816- } ) ,
817- ) ;
818- } ) ;
743+ expect ( joinResult . joinOrganization ) . toEqual (
744+ expect . objectContaining ( {
745+ __typename : 'OrganizationInvitationError' ,
746+ message :
747+ 'The user is not authorized through the OIDC integration required for the organization' ,
748+ } ) ,
749+ ) ;
750+ } ,
751+ ) ;
819752
820753 test . concurrent ( 'non-oidc users can join an organization (opt-in)' , async ( { expect } ) => {
821754 const seed = initSeed ( ) ;
@@ -925,10 +858,8 @@ test.concurrent(
925858 const seed = initSeed ( ) ;
926859 const { createOrg, ownerToken } = await seed . createOwner ( ) ;
927860 const { organization, inviteAndJoinMember } = await createOrg ( ) ;
928- const { createMemberRole, assignMemberRole, updateMemberRole, memberToken, member } =
929- await inviteAndJoinMember ( ) ;
930861
931- await execute ( {
862+ const createOIDCIntegrationResult = await execute ( {
932863 document : CreateOIDCIntegrationMutation ,
933864 variables : {
934865 input : {
@@ -942,7 +873,11 @@ test.concurrent(
942873 } ,
943874 authToken : ownerToken ,
944875 } ) . then ( r => r . expectNoGraphQLErrors ( ) ) ;
876+ const oidcIntegrationId =
877+ createOIDCIntegrationResult . createOIDCIntegration . ok ?. createdOIDCIntegration . id ;
945878
879+ const { createMemberRole, assignMemberRole, updateMemberRole, memberToken, member } =
880+ await inviteAndJoinMember ( { oidcIntegrationId } ) ;
946881 const role = await createMemberRole ( [ ] ) ;
947882 await assignMemberRole ( { roleId : role . id , userId : member . id } ) ;
948883
0 commit comments