Skip to content

Commit d626e20

Browse files
committed
Update API controller tests to assert unauthorized access instead of redirect
1 parent 9371f1a commit d626e20

File tree

6 files changed

+11
-26
lines changed

6 files changed

+11
-26
lines changed

templates/install.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
param([string] $packagesVersions, [string]$gitBranchName = 'dev')
1+
param([string] $packagesVersions)
22

3-
./0-build-template.ps1 -packagesVersions $packagesVersions -gitBranchName $gitBranchName
3+
./0-build-template.ps1 -packagesVersions $packagesVersions
44

55
./1-add-docker-support.ps1
66

tests/Skoruba.Duende.IdentityServer.Admin.Api.IntegrationTests/Tests/ApiResourcesControllerTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ public async Task GetApiResourcesWithoutPermissions()
3737
var response = await Client.GetAsync("api/apiresources");
3838

3939
// Assert
40-
response.StatusCode.Should().Be(HttpStatusCode.Redirect);
41-
42-
//The redirect to login
43-
response.Headers.Location?.ToString().Should().Contain(AuthenticationConsts.AccountLoginPage);
40+
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
4441
}
4542
}
46-
}
43+
}

tests/Skoruba.Duende.IdentityServer.Admin.Api.IntegrationTests/Tests/ClientsControllerTests.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ public async Task GetClientsWithoutPermissions()
3636
var response = await Client.GetAsync("api/clients");
3737

3838
// Assert
39-
response.StatusCode.Should().Be(HttpStatusCode.Redirect);
40-
41-
//The redirect to login
42-
response.Headers.Location.ToString().Should().Contain(AuthenticationConsts.AccountLoginPage);
39+
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
4340
}
4441
}
4542
}

tests/Skoruba.Duende.IdentityServer.Admin.Api.IntegrationTests/Tests/IdentityResourcesControllerTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ public async Task GetIdentityResourcesWithoutPermissions()
3636
var response = await Client.GetAsync("api/identityresources");
3737

3838
// Assert
39-
response.StatusCode.Should().Be(HttpStatusCode.Redirect);
40-
41-
//The redirect to login
42-
response.Headers.Location.ToString().Should().Contain(AuthenticationConsts.AccountLoginPage);
39+
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
4340
}
4441
}
45-
}
42+
}

tests/Skoruba.Duende.IdentityServer.Admin.Api.IntegrationTests/Tests/RolesControllerTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ public async Task GetRolesWithoutPermissions()
3636
var response = await Client.GetAsync("api/roles");
3737

3838
// Assert
39-
response.StatusCode.Should().Be(HttpStatusCode.Redirect);
40-
41-
//The redirect to login
42-
response.Headers.Location.ToString().Should().Contain(AuthenticationConsts.AccountLoginPage);
39+
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
4340
}
4441
}
45-
}
42+
}

tests/Skoruba.Duende.IdentityServer.Admin.Api.IntegrationTests/Tests/UsersControllerTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ public async Task GetRolesWithoutPermissions()
3636
var response = await Client.GetAsync("api/users");
3737

3838
// Assert
39-
response.StatusCode.Should().Be(HttpStatusCode.Redirect);
40-
41-
//The redirect to login
42-
response.Headers.Location.ToString().Should().Contain(AuthenticationConsts.AccountLoginPage);
39+
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
4340
}
4441
}
45-
}
42+
}

0 commit comments

Comments
 (0)