-
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.
- Loading branch information
1 parent
720f43b
commit a1d1ba3
Showing
4 changed files
with
105 additions
and
136 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 |
---|---|---|
|
@@ -6,42 +6,39 @@ import akka.http.scaladsl.server.Route | |
import akka.http.scaladsl.testkit.ScalatestRouteTest | ||
import org.broadinstitute.dsde.workbench.model.WorkbenchEmail | ||
import org.broadinstitute.dsde.workbench.sam.TestSupport.{databaseEnabled, databaseEnabledClue} | ||
import org.broadinstitute.dsde.workbench.sam.model.api.TermsOfServiceConfigResponse | ||
import org.broadinstitute.dsde.workbench.sam.model.api.SamJsonSupport._ | ||
import org.broadinstitute.dsde.workbench.sam.model.api.SamUser | ||
import org.broadinstitute.dsde.workbench.sam.model.api.{SamUser, TermsOfServiceConfigResponse} | ||
import org.broadinstitute.dsde.workbench.sam.model.{BasicWorkbenchGroup, TermsOfServiceDetails} | ||
import org.broadinstitute.dsde.workbench.sam.service.CloudExtensions | ||
import org.broadinstitute.dsde.workbench.sam.{Generator, TestSupport} | ||
import org.scalatest.concurrent.Eventually.eventually | ||
import org.scalatest.funspec.AnyFunSpec | ||
import org.scalatest.matchers.should.Matchers | ||
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ | ||
|
||
class TermsOfServiceRouteSpec extends AnyFunSpec with Matchers with ScalatestRouteTest with TestSupport { | ||
val samRoutes: TestSamRoutes = TestSamRoutes(Map.empty) | ||
|
||
describe("GET /tos/text") { | ||
it("should return the tos text") { | ||
assume(databaseEnabled, databaseEnabledClue) | ||
"GET /termsOfService/v1" should "return the current tos config" in { | ||
|
||
val samRoutes = TestSamRoutes(Map.empty) | ||
eventually { | ||
Get("/termsOfService/v1") ~> samRoutes.route ~> check { | ||
status shouldEqual StatusCodes.OK | ||
responseAs[TermsOfServiceConfigResponse] shouldBe TermsOfServiceConfigResponse( | ||
enforced = true, | ||
currentVersion = "0", | ||
inGracePeriod = false, | ||
inRollingAcceptanceWindow = false | ||
) | ||
describe("GET /termsOfService/v1") { | ||
it("return the current tos config") { | ||
val samRoutes = TestSamRoutes(Map.empty) | ||
eventually { | ||
Get("/termsOfService/v1") ~> samRoutes.route ~> check { | ||
status shouldEqual StatusCodes.OK | ||
responseAs[TermsOfServiceConfigResponse] shouldBe TermsOfServiceConfigResponse( | ||
enforced = true, | ||
currentVersion = "0", | ||
inGracePeriod = false, | ||
inRollingAcceptanceWindow = false | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
"GET /tos/text" should "return the tos text" in { | ||
assume(databaseEnabled, databaseEnabledClue) | ||
describe("GET /tos/text") { | ||
it("return the tos text") { | ||
assume(databaseEnabled, databaseEnabledClue) | ||
|
||
val samRoutes = TestSamRoutes(Map.empty) | ||
eventually { | ||
Get("/tos/text") ~> samRoutes.route ~> check { | ||
status shouldEqual StatusCodes.OK | ||
|
@@ -52,15 +49,19 @@ class TermsOfServiceRouteSpec extends AnyFunSpec with Matchers with ScalatestRou | |
} | ||
|
||
describe("GET /privacy/text") { | ||
it("should return the privacy policy text") { | ||
Get("/privacy/text") ~> samRoutes.route ~> check { | ||
status shouldEqual StatusCodes.OK | ||
responseAs[String].isEmpty shouldBe false | ||
it("return the privacy policy text") { | ||
val samRoutes = TestSamRoutes(Map.empty) | ||
eventually { | ||
Get("/privacy/text") ~> samRoutes.route ~> check { | ||
status shouldEqual StatusCodes.OK | ||
responseAs[String].isEmpty shouldBe false | ||
} | ||
} | ||
} | ||
} | ||
|
||
describe("GET /api/termsOfService/v1") { | ||
val samRoutes = TestSamRoutes(Map.empty) | ||
it("should be a valid route") { | ||
Get("/api/termsOfService/v1") ~> samRoutes.route ~> check { | ||
status shouldBe StatusCodes.NotImplemented | ||
|
@@ -69,6 +70,7 @@ class TermsOfServiceRouteSpec extends AnyFunSpec with Matchers with ScalatestRou | |
} | ||
|
||
describe("GET /api/termsOfService/v1/docs") { | ||
val samRoutes = TestSamRoutes(Map.empty) | ||
it("should be a valid route") { | ||
Get("/api/termsOfService/v1/docs") ~> samRoutes.route ~> check { | ||
status shouldBe StatusCodes.NotImplemented | ||
|
@@ -77,6 +79,7 @@ class TermsOfServiceRouteSpec extends AnyFunSpec with Matchers with ScalatestRou | |
} | ||
|
||
describe("GET /api/termsOfService/v1/docs/redirect") { | ||
val samRoutes = TestSamRoutes(Map.empty) | ||
it("should be a valid route") { | ||
Get("/api/termsOfService/v1/docs/redirect") ~> samRoutes.route ~> check { | ||
status shouldBe StatusCodes.NotImplemented | ||
|
@@ -85,6 +88,7 @@ class TermsOfServiceRouteSpec extends AnyFunSpec with Matchers with ScalatestRou | |
} | ||
|
||
describe("GET /api/termsOfService/v1/user") { | ||
val samRoutes = TestSamRoutes(Map.empty) | ||
it("should not be handled") { | ||
Get("/api/termsOfService/v1/user") ~> samRoutes.route ~> check { | ||
assert(!handled, "`GET /api/termsOfService/v1/user` should not be a handled route") | ||
|
@@ -93,6 +97,7 @@ class TermsOfServiceRouteSpec extends AnyFunSpec with Matchers with ScalatestRou | |
} | ||
|
||
describe("GET /api/termsOfService/v1/user/self") { | ||
val samRoutes = TestSamRoutes(Map.empty) | ||
it("should return an instance of `TermsOfServiceDetails`") { | ||
Get("/api/termsOfService/v1/user/self") ~> samRoutes.route ~> check { | ||
withClue(s"${responseAs[String]} is not parsable as an instance of `TermsOfServiceDetails`.") { | ||
|
@@ -104,6 +109,7 @@ class TermsOfServiceRouteSpec extends AnyFunSpec with Matchers with ScalatestRou | |
} | ||
|
||
describe("GET /api/termsOfService/v1/user/{USER_ID}") { | ||
val samRoutes = TestSamRoutes(Map.empty) | ||
it("should return an instance of `TermsOfServiceDetails`") { | ||
val allUsersGroup: BasicWorkbenchGroup = BasicWorkbenchGroup(CloudExtensions.allUsersGroupName, Set(), WorkbenchEmail("[email protected]")) | ||
val defaultUser: SamUser = Generator.genWorkbenchUserGoogle.sample.get | ||
|
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