Skip to content

Commit

Permalink
ID-808, ID-809 Implement PUT /api/termsOfService/v1/user/self/accept …
Browse files Browse the repository at this point in the history
…and reject (#1249)

* ID-808 Implement PUT /api/termsOfService/v1/user/self/accept

* Implement PUT /api/termsOfService/v1/user/self/reject
  • Loading branch information
Ghost-in-a-Jar authored Nov 9, 2023
1 parent e08c499 commit 2027ee1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
19 changes: 18 additions & 1 deletion src/main/resources/swagger/api-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3320,7 +3320,24 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorReport'

/termsOfService/v1/user/self/accept:
get:
tags:
- TermsOfService
summary: Accepts the current terms of service for the requesting user.
operationId: userTermsOfServiceAcceptSelf
responses:
204:
description: OK
/termsOfService/v1/user/self/reject:
get:
tags:
- TermsOfService
summary: Rejects the current terms of service for the requesting user.
operationId: userTermsOfServiceRejectSelf
responses:
204:
description: OK
/termsOfService/v1/user/{sam_user_id}:
get:
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ trait TermsOfServiceRoutes extends SamUserDirectives {
pathPrefix("accept") { // api/termsOfService/v1/user/accept
pathEndOrSingleSlash {
put {
complete(StatusCodes.NotImplemented)
complete(tosService.acceptTosStatus(samUser.id, samRequestContext).map(_ => StatusCodes.NoContent))
}
}
} ~
pathPrefix("reject") { // api/termsOfService/v1/user/reject
pathEndOrSingleSlash {
put {
complete(StatusCodes.NotImplemented)
complete(tosService.rejectTosStatus(samUser.id, samRequestContext).map(_ => StatusCodes.NoContent))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,23 @@ class TermsOfServiceRouteSpec extends AnyFunSpec with Matchers with ScalatestRou
}
}

it("should return 204 when tos accepted") {
val samRoutes = TestSamRoutes(Map.empty)
eventually {
Put("/api/termsOfService/v1/user/self/accept") ~> samRoutes.route ~> check {
status shouldEqual StatusCodes.NoContent
responseAs[String] shouldBe ""
}
}
}

it("should return 204 when tos rejected") {
val samRoutes = TestSamRoutes(Map.empty)
eventually {
Put("/api/termsOfService/v1/user/self/reject") ~> samRoutes.route ~> check {
status shouldEqual StatusCodes.NoContent
responseAs[String] shouldBe ""
}
}
}
}

0 comments on commit 2027ee1

Please sign in to comment.