-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move TOS admin enforcement to route level (#1622)
- Loading branch information
Showing
4 changed files
with
74 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,13 +139,26 @@ class TermsOfServiceRouteSpec extends AnyFunSpec with Matchers with ScalatestRou | |
} | ||
} | ||
|
||
it("should return 404 when USER_ID is does not exist") { | ||
it("should return 401 when called as non-admin to inspect another user") { | ||
val defaultUser = Generator.genWorkbenchUserGoogle.sample.get | ||
val allUsersGroup: BasicWorkbenchGroup = BasicWorkbenchGroup(CloudExtensions.allUsersGroupName, Set(), WorkbenchEmail("[email protected]")) | ||
val mockSamRoutesBuilder = new MockSamRoutesBuilder(allUsersGroup) | ||
.withEnabledUser(defaultUser) | ||
.withAllowedUser(defaultUser) | ||
|
||
Get("/api/termsOfService/v1/user/12345abc") ~> Route.seal(mockSamRoutesBuilder.build.route) ~> check { | ||
status shouldEqual StatusCodes.Unauthorized | ||
} | ||
} | ||
|
||
it("should return 404 when called as admin and USER_ID does not exist") { | ||
val defaultUser = Generator.genWorkbenchUserGoogle.sample.get | ||
val allUsersGroup: BasicWorkbenchGroup = BasicWorkbenchGroup(CloudExtensions.allUsersGroupName, Set(), WorkbenchEmail("[email protected]")) | ||
val mockSamRoutesBuilder = new MockSamRoutesBuilder(allUsersGroup) | ||
.callAsAdminUser() | ||
.withEnabledUser(defaultUser) | ||
.withAllowedUser(defaultUser) | ||
|
||
Get("/api/termsOfService/v1/user/12345abc") ~> Route.seal(mockSamRoutesBuilder.build.route) ~> check { | ||
status shouldEqual StatusCodes.NotFound | ||
} | ||
|
@@ -181,10 +194,23 @@ class TermsOfServiceRouteSpec extends AnyFunSpec with Matchers with ScalatestRou | |
} | ||
} | ||
|
||
it("should return 200 with empty list when user has no acceptance history") { | ||
it("should return 401 when called as non-admin to inspect another user") { | ||
val defaultUser = Generator.genWorkbenchUserGoogle.sample.get | ||
val allUsersGroup: BasicWorkbenchGroup = BasicWorkbenchGroup(CloudExtensions.allUsersGroupName, Set(), WorkbenchEmail("[email protected]")) | ||
val mockSamRoutesBuilder = new MockSamRoutesBuilder(allUsersGroup) | ||
.withEnabledUser(defaultUser) | ||
.withAllowedUser(defaultUser) | ||
|
||
Get("/api/termsOfService/v1/user/12345abc/history") ~> Route.seal(mockSamRoutesBuilder.build.route) ~> check { | ||
status shouldEqual StatusCodes.Unauthorized | ||
} | ||
} | ||
|
||
it("should return 200 with empty list when called as admin and user has no acceptance history") { | ||
val defaultUser = Generator.genWorkbenchUserGoogle.sample.get | ||
val allUsersGroup: BasicWorkbenchGroup = BasicWorkbenchGroup(CloudExtensions.allUsersGroupName, Set(), WorkbenchEmail("[email protected]")) | ||
val mockSamRoutesBuilder = new MockSamRoutesBuilder(allUsersGroup) | ||
.callAsAdminUser() | ||
.withEnabledUser(defaultUser) | ||
.withAllowedUser(defaultUser) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters