2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-09-08 02:05:10 +00:00

add tests

This commit is contained in:
Aravindh-Raju
2023-05-16 12:07:58 +05:30
parent 9b9a4a875d
commit c97465a4c9
2 changed files with 57 additions and 0 deletions

View File

@@ -238,6 +238,32 @@ class FrontendControllerSpec extends Specification with Mockito with TestApplica
}
}
"Get for '/recordsets'" should {
"redirect to the login page when a user is not logged in" in new WithApplication(app) {
val result = underTest.viewRecordSets()(FakeRequest(GET, "/recordsets"))
status(result) must equalTo(SEE_OTHER)
headers(result) must contain("Location" -> "/login?target=/recordsets")
}
"render the recordset view page when the user is logged in" in new WithApplication(app) {
val result =
underTest.viewRecordSets()(
FakeRequest(GET, "/recordsets").withSession("username" -> "frodo").withCSRFToken
)
status(result) must beEqualTo(OK)
contentType(result) must beSome.which(_ == "text/html")
contentAsString(result) must contain("RecordSets | VinylDNS")
}
"redirect to the no access page when a user is locked out" in new WithApplication(app) {
val result =
lockedUserUnderTest.viewRecordSets()(
FakeRequest(GET, "/recordsets")
.withSession("username" -> "lockedFbaggins")
.withCSRFToken
)
headers(result) must contain("Location" -> "/noaccess")
}
}
"Get for login" should {
"with ldap enabled" should {
"render the login page when the user is not logged in" in new WithApplication(app) {