@@ -669,5 +669,77 @@ public async Task Returns400WhenUnableToDecodeBeforeToken()
669669
670670 response . StatusCode . Should ( ) . Be ( 400 ) ;
671671 }
672+
673+ [ Test ]
674+ public async Task Returns200WhenItCanUpdateClaimsGroupId ( )
675+ {
676+ var oldGroupId = Guid . NewGuid ( ) ;
677+ var newGroupId = Guid . NewGuid ( ) ;
678+ var claim1 = TestDataHelper . CreateClaim ( ) . ToEntity ( ) ;
679+ var claim2 = TestDataHelper . CreateClaim ( ) . ToEntity ( ) ;
680+ var claim3 = TestDataHelper . CreateClaim ( ) . ToEntity ( ) ;
681+ claim1 . GroupId = oldGroupId ;
682+ claim2 . GroupId = oldGroupId ;
683+ claim3 . GroupId = oldGroupId ;
684+ DatabaseContext . Add ( claim1 ) ;
685+ DatabaseContext . Add ( claim2 ) ;
686+ DatabaseContext . Add ( claim3 ) ;
687+ DatabaseContext . SaveChanges ( ) ;
688+
689+ var uri = new Uri ( "api/v1/claims/update" , UriKind . Relative ) ;
690+ Client . DefaultRequestHeaders . Add ( "Authorization" , TestToken . Value ) ;
691+ string body = "{" +
692+ $ "\" oldGroupId\" : \" { oldGroupId } \" ," +
693+ $ "\" newGroupId\" : \" { newGroupId } \" " +
694+ "}" ;
695+
696+ var jsonString = new StringContent ( body , Encoding . UTF8 , "application/json" ) ;
697+ var response = await Client . PostAsync ( uri , jsonString ) . ConfigureAwait ( true ) ;
698+
699+ response . StatusCode . Should ( ) . Be ( 200 ) ;
700+ }
701+
702+ [ Test ]
703+ public async Task Returns400WithInvalidParameters ( )
704+ {
705+ var oldGroupId = Guid . NewGuid ( ) ;
706+ var newGroupId = "abc" ;
707+ var uri = new Uri ( "api/v1/claims/update" , UriKind . Relative ) ;
708+ Client . DefaultRequestHeaders . Add ( "Authorization" , TestToken . Value ) ;
709+ string body = "{" +
710+ $ "\" oldGroupId\" : \" { oldGroupId } \" ," +
711+ $ "\" newGroupId\" : \" { newGroupId } \" " +
712+ "}" ;
713+
714+ var jsonString = new StringContent ( body , Encoding . UTF8 , "application/json" ) ;
715+ var response = await Client . PostAsync ( uri , jsonString ) . ConfigureAwait ( true ) ;
716+
717+ response . StatusCode . Should ( ) . Be ( 400 ) ;
718+ }
719+
720+ [ Test ]
721+ public async Task Returns200ButEmptyCollectionWhenCannotFindClaimsForGroupId ( )
722+ {
723+ var oldGroupId = Guid . NewGuid ( ) ;
724+ var newGroupId = Guid . NewGuid ( ) ;
725+ var claim1 = TestDataHelper . CreateClaim ( ) . ToEntity ( ) ;
726+ var claim2 = TestDataHelper . CreateClaim ( ) . ToEntity ( ) ;
727+ DatabaseContext . Add ( claim1 ) ;
728+ DatabaseContext . Add ( claim2 ) ;
729+ DatabaseContext . SaveChanges ( ) ;
730+
731+ var uri = new Uri ( "api/v1/claims/update" , UriKind . Relative ) ;
732+ Client . DefaultRequestHeaders . Add ( "Authorization" , TestToken . Value ) ;
733+ string body = "{" +
734+ $ "\" oldGroupId\" : \" { oldGroupId } \" ," +
735+ $ "\" newGroupId\" : \" { newGroupId } \" " +
736+ "}" ;
737+
738+ var jsonString = new StringContent ( body , Encoding . UTF8 , "application/json" ) ;
739+ var response = await Client . PostAsync ( uri , jsonString ) . ConfigureAwait ( true ) ;
740+ var json = await response . Content . ReadAsStringAsync ( ) ;
741+ response . StatusCode . Should ( ) . Be ( 200 ) ;
742+ json . Should ( ) . Be ( "[]" ) ;
743+ }
672744 }
673745}
0 commit comments