fixed tests
continuous-integration/drone/push Build is passing Details

dev
Override-6 2 years ago
parent 9c9917ff9f
commit a3065f64af

@ -78,7 +78,7 @@ class Authenticator(url: URL, key: PublicKey, algorithm: JwtAsymmetricAlgorithm)
findByMail(mail)
.someOrFail(UserNotFound) // await one second if password fails to reduce bruteforce //FIXME this wont actually reduce bruteforce
.filterOrElse(_.passwordHash == hashPassword(password))(ZIO.sleep(1.second) *> ZIO.fail(InvalidPassword))
.filterOrElse(_.passwordHash == hashPassword(password))(Clock.sleep(1.seconds) *> ZIO.fail(InvalidPassword))
}
private def insert(user: User) = quote {

@ -1,33 +1,33 @@
{
"results": [
{
"name" : "Test Task name not available here/\/login page handler/login situation tests/login with unknown account",
"name" : "Test Task name not available here/\/login page handler/login situation tests/login with known account wrong password",
"status" : "Success",
"durationMillis" : "3877",
"durationMillis" : "5030",
"annotations" : "",
"fullyQualifiedClassName" : "Test Task name not available here",
"labels" : ["\/login page handler", "login situation tests", "login with unknown account"]
"labels" : ["\/login page handler", "login situation tests", "login with known account wrong password"]
},
{
"name" : "Test Task name not available here/\/login page handler/login situation tests/login with known account",
"name" : "Test Task name not available here/\/login page handler/login situation tests/login with unknown account",
"status" : "Success",
"durationMillis" : "4862",
"durationMillis" : "5077",
"annotations" : "",
"fullyQualifiedClassName" : "Test Task name not available here",
"labels" : ["\/login page handler", "login situation tests", "login with known account"]
"labels" : ["\/login page handler", "login situation tests", "login with unknown account"]
},
{
"name" : "Test Task name not available here/\/login page handler/erroned request body tests/empty packet",
"name" : "Test Task name not available here/\/login page handler/login situation tests/login with known account",
"status" : "Success",
"durationMillis" : "2683",
"durationMillis" : "6398",
"annotations" : "",
"fullyQualifiedClassName" : "Test Task name not available here",
"labels" : ["\/login page handler", "erroned request body tests", "empty packet"]
"labels" : ["\/login page handler", "login situation tests", "login with known account"]
},
{
"name" : "Test Task name not available here/\/login page handler/erroned request body tests/with no password attribute",
"status" : "Success",
"durationMillis" : "2698",
"durationMillis" : "3098",
"annotations" : "",
"fullyQualifiedClassName" : "Test Task name not available here",
"labels" : ["\/login page handler", "erroned request body tests", "with no password attribute"]
@ -35,15 +35,23 @@
{
"name" : "Test Task name not available here/\/login page handler/erroned request body tests/with no mail attribute",
"status" : "Success",
"durationMillis" : "2697",
"durationMillis" : "3172",
"annotations" : "",
"fullyQualifiedClassName" : "Test Task name not available here",
"labels" : ["\/login page handler", "erroned request body tests", "with no mail attribute"]
},
{
"name" : "Test Task name not available here/\/login page handler/erroned request body tests/empty packet",
"status" : "Success",
"durationMillis" : "3200",
"annotations" : "",
"fullyQualifiedClassName" : "Test Task name not available here",
"labels" : ["\/login page handler", "erroned request body tests", "empty packet"]
},
{
"name" : "Test Task name not available here/\/login page handler/erroned request body tests/with invalid json",
"status" : "Success",
"durationMillis" : "2679",
"durationMillis" : "3251",
"annotations" : "",
"fullyQualifiedClassName" : "Test Task name not available here",
"labels" : ["\/login page handler", "erroned request body tests", "with invalid json"]

@ -77,15 +77,17 @@ object LoginPageHandlerTests extends ZIOSpecDefault {
},
test("login with known account wrong password") {
val requestJson = """{"password":"this is a wrong password","email":"maximebatista18@gmail.com"}"""
for
response <- post(Request.post(Body.fromString("""{"password":"this is a wrong password","email":"maximebatista18@gmail.com"}"""), URL.empty))
fiber <- post(Request.post(Body.fromString(requestJson), URL.empty)).fork
_ <- TestClock.adjust(1.seconds)
response <- ZIO.fromFiber(fiber)
json <- getJsonBody(response)
errorType <- parseAttribute(json, "error", JsonCursor.field("error").isString)
errorMsg <- parseAttribute(json, "msg", JsonCursor.field("msg").isString)
yield
assert(errorType)(equalTo("unauthorized"))
&& assert(errorMsg)(equalTo("invalid password"))
&& assert(response)(hasField("headers", _.headers, hasSameElements(Headers.location("/register"))))
}
)
}