org.http4k.hamkrest.cookie.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http4k-testing-hamkrest Show documentation
Show all versions of http4k-testing-hamkrest Show documentation
A set of Hamkrest matchers for common http4k types
package org.http4k.hamkrest
import com.natpryce.hamkrest.Matcher
import com.natpryce.hamkrest.equalTo
import com.natpryce.hamkrest.has
import com.natpryce.hamkrest.present
import org.http4k.core.cookie.Cookie
import org.http4k.core.cookie.SameSite
import java.time.Instant
fun hasCookieName(expected: CharSequence): Matcher = has(Cookie::name, equalTo(expected))
@JvmName("hasCookieValueNullableString")
fun hasCookieValue(matcher: Matcher): Matcher = has(Cookie::value, matcher)
fun hasCookieValue(matcher: Matcher): Matcher = has(Cookie::value, present(matcher))
fun hasCookieValue(expected: CharSequence): Matcher = has(Cookie::value, equalTo(expected))
fun hasCookieDomain(expected: CharSequence): Matcher = has("domain", { c: Cookie -> c.domain }, equalTo(expected))
fun hasCookiePath(expected: CharSequence): Matcher = has("path", { c: Cookie -> c.path }, equalTo(expected))
fun isSecureCookie(expected: Boolean = true): Matcher = has("secure", { c: Cookie -> c.secure }, equalTo(expected))
fun isHttpOnlyCookie(expected: Boolean = true): Matcher = has("httpOnly", { c: Cookie -> c.httpOnly }, equalTo(expected))
fun hasCookieExpiry(expected: Instant): Matcher = hasCookieExpiry(equalTo(expected))
fun hasCookieExpiry(matcher: Matcher): Matcher = has("expiry", { c: Cookie -> c.expires!! }, matcher)
fun hasCookieSameSite(expected: SameSite): Matcher = has("sameSite", { c: Cookie -> c.sameSite }, equalTo(expected))
© 2015 - 2025 Weber Informatics LLC | Privacy Policy