@@ -342,6 +342,60 @@ func TestGroupSyncTable(t *testing.T) {
342342})
343343}
344344
345+ func TestSyncDisabled (t * testing.T ) {
346+ t .Parallel ()
347+
348+ if dbtestutil .WillUsePostgres () {
349+ t .Skip ("Skipping test because it populates a lot of db entries, which is slow on postgres." )
350+ }
351+
352+ db ,_ := dbtestutil .NewDB (t )
353+ manager := runtimeconfig .NewManager ()
354+ s := idpsync .NewAGPLSync (slogtest .Make (t ,& slogtest.Options {}),
355+ manager ,
356+ idpsync.DeploymentSyncSettings {},
357+ )
358+
359+ ids := coderdtest .NewDeterministicUUIDGenerator ()
360+ ctx := testutil .Context (t ,testutil .WaitSuperLong )
361+ user := dbgen .User (t ,db , database.User {})
362+ orgID := uuid .New ()
363+
364+ def := orgSetupDefinition {
365+ Name :"SyncDisabled" ,
366+ Groups :map [uuid.UUID ]bool {
367+ ids .ID ("foo" ):true ,
368+ ids .ID ("bar" ):true ,
369+ ids .ID ("baz" ):false ,
370+ ids .ID ("bop" ):false ,
371+ },
372+ Settings :& idpsync.GroupSyncSettings {
373+ Field :"groups" ,
374+ Mapping :map [string ][]uuid.UUID {
375+ "foo" : {ids .ID ("foo" )},
376+ "baz" : {ids .ID ("baz" )},
377+ },
378+ },
379+ ExpectedGroups : []uuid.UUID {
380+ ids .ID ("foo" ),
381+ ids .ID ("bar" ),
382+ },
383+ }
384+
385+ SetupOrganization (t ,s ,db ,user ,orgID ,def )
386+
387+ // Do the group sync!
388+ err := s .SyncGroups (ctx ,db ,user , idpsync.GroupParams {
389+ SyncEnabled :false ,
390+ MergedClaims : jwt.MapClaims {
391+ "groups" : []string {"baz" ,"bop" },
392+ },
393+ })
394+ require .NoError (t ,err )
395+
396+ def .Assert (t ,orgID ,db ,user )
397+ }
398+
345399// TestApplyGroupDifference is mainly testing the database functions
346400func TestApplyGroupDifference (t * testing.T ) {
347401t .Parallel ()