@@ -16,6 +16,7 @@ public FetchResourceTests(IntegrationTestContext<TestableStartup<ReadWriteDbCont
1616 _testContext = testContext ;
1717
1818 testContext . UseController < WorkItemsController > ( ) ;
19+ testContext . UseController < WorkItemGroupsController > ( ) ;
1920 testContext . UseController < UserAccountsController > ( ) ;
2021 testContext . UseController < WorkTagsController > ( ) ;
2122 }
@@ -191,6 +192,34 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
191192 responseDocument . Data . Value . Should ( ) . BeNull ( ) ;
192193 }
193194
195+ [ Fact ]
196+ public async Task Cannot_get_secondary_ManyToOne_resource_with_blocked_capability ( )
197+ {
198+ // Arrange
199+ WorkItem workItem = _fakers . WorkItem . GenerateOne ( ) ;
200+
201+ await _testContext . RunOnDatabaseAsync ( async dbContext =>
202+ {
203+ dbContext . WorkItems . Add ( workItem ) ;
204+ await dbContext . SaveChangesAsync ( ) ;
205+ } ) ;
206+
207+ string route = $ "/workItems/{ workItem . StringId } /group";
208+
209+ // Act
210+ ( HttpResponseMessage httpResponse , Document responseDocument ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
211+
212+ // Assert
213+ httpResponse . ShouldHaveStatusCode ( HttpStatusCode . Forbidden ) ;
214+
215+ responseDocument . Errors . Should ( ) . HaveCount ( 1 ) ;
216+
217+ ErrorObject error = responseDocument . Errors [ 0 ] ;
218+ error . StatusCode . Should ( ) . Be ( HttpStatusCode . Forbidden ) ;
219+ error . Title . Should ( ) . Be ( "The requested endpoint is not accessible." ) ;
220+ error . Detail . Should ( ) . Be ( "Retrieving the relationship 'group' of type 'workItems' is not allowed." ) ;
221+ }
222+
194223 [ Fact ]
195224 public async Task Can_get_secondary_OneToMany_resources ( )
196225 {
@@ -252,6 +281,34 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
252281 responseDocument . Data . ManyValue . Should ( ) . BeEmpty ( ) ;
253282 }
254283
284+ [ Fact ]
285+ public async Task Cannot_get_secondary_OneToMany_resources_with_blocked_capability ( )
286+ {
287+ // Arrange
288+ WorkItemGroup group = _fakers . WorkItemGroup . GenerateOne ( ) ;
289+
290+ await _testContext . RunOnDatabaseAsync ( async dbContext =>
291+ {
292+ dbContext . Groups . Add ( group ) ;
293+ await dbContext . SaveChangesAsync ( ) ;
294+ } ) ;
295+
296+ string route = $ "/workItemGroups/{ group . StringId } /items";
297+
298+ // Act
299+ ( HttpResponseMessage httpResponse , Document responseDocument ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
300+
301+ // Assert
302+ httpResponse . ShouldHaveStatusCode ( HttpStatusCode . Forbidden ) ;
303+
304+ responseDocument . Errors . Should ( ) . HaveCount ( 1 ) ;
305+
306+ ErrorObject error = responseDocument . Errors [ 0 ] ;
307+ error . StatusCode . Should ( ) . Be ( HttpStatusCode . Forbidden ) ;
308+ error . Title . Should ( ) . Be ( "The requested endpoint is not accessible." ) ;
309+ error . Detail . Should ( ) . Be ( "Retrieving the relationship 'items' of type 'workItemGroups' is not allowed." ) ;
310+ }
311+
255312 [ Fact ]
256313 public async Task Can_get_secondary_ManyToMany_resources ( )
257314 {
0 commit comments