All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.http4k.hamkrest.cookie.kt Maven / Gradle / Ivy

There is a newer version: 5.41.0.0
Show newest version
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 java.time.LocalDateTime

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: LocalDateTime): Matcher = hasCookieExpiry(equalTo(expected))

fun hasCookieExpiry(matcher: Matcher): Matcher = has("expiry", { c: Cookie -> c.expires!! }, matcher)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy