Added submitHam and submitSpam tests.
This commit is contained in:
parent
ccc2daaae8
commit
66fdd46fd8
1 changed files with 94 additions and 40 deletions
|
@ -51,14 +51,6 @@ import java.util.logging.ConsoleHandler
|
||||||
import java.util.logging.Level
|
import java.util.logging.Level
|
||||||
import javax.servlet.http.HttpServletRequest
|
import javax.servlet.http.HttpServletRequest
|
||||||
|
|
||||||
/**
|
|
||||||
* The <code>AkismetTest</code> class.
|
|
||||||
*
|
|
||||||
* @author <a href="https://erik.thauvin.net/" target="_blank">Erik C. Thauvin</a>
|
|
||||||
* @created 2019-09-17
|
|
||||||
* @since 1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun getApiKey(): String {
|
fun getApiKey(): String {
|
||||||
var apiKey = System.getenv("AKISMET_API_KEY") ?: ""
|
var apiKey = System.getenv("AKISMET_API_KEY") ?: ""
|
||||||
if (apiKey.isBlank()) {
|
if (apiKey.isBlank()) {
|
||||||
|
@ -119,44 +111,106 @@ class AkismetTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun verifyKeyTest() {
|
fun verifyKeyTest() {
|
||||||
assertFalse(akismet.isValidKey, "isValidKey -> false")
|
assertFalse(akismet.isVerifiedKey, "isVerifiedKey -> false")
|
||||||
assertTrue(akismet.verifyKey(), "verify_key")
|
assertTrue(akismet.verifyKey(), "verify_key")
|
||||||
assertTrue(akismet.isValidKey, "isValidKey -> true")
|
assertTrue(akismet.isVerifiedKey, "isVerifiedKey -> true")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun checkCommentTest() {
|
fun checkCommentTest() {
|
||||||
// assertFalse(akismet.checkComment(userIp = userIp,
|
assertFalse(
|
||||||
// userAgent = userAgent,
|
akismet.checkComment(
|
||||||
// referrer = referrer,
|
userIp = userIp,
|
||||||
// permalink = permalink,
|
userAgent = userAgent,
|
||||||
// type = type,
|
referrer = referrer,
|
||||||
// author = author,
|
permalink = permalink,
|
||||||
// authorEmail = authorEmail,
|
type = type,
|
||||||
// authorUrl = authorUrl,
|
author = author,
|
||||||
// content = content,
|
authorEmail = authorEmail,
|
||||||
// userRole = Akismet.ADMIN_ROLE,
|
authorUrl = authorUrl,
|
||||||
// isTest = true), "check_comment -> false")
|
content = content,
|
||||||
//
|
userRole = Akismet.ADMIN_ROLE,
|
||||||
// assertTrue(akismet.checkComment(userIp = userIp,
|
isTest = true), "check_comment -> false")
|
||||||
// userAgent = userAgent,
|
|
||||||
// referrer = referrer,
|
assertTrue(
|
||||||
// permalink = permalink,
|
akismet.checkComment(
|
||||||
// type = type,
|
userIp = userIp,
|
||||||
// author = author,
|
userAgent = userAgent,
|
||||||
// authorEmail = authorEmail,
|
referrer = referrer,
|
||||||
// authorUrl = authorUrl,
|
permalink = permalink,
|
||||||
// content = content,
|
type = type,
|
||||||
// isTest = true), "check_comment -> true")
|
author = author,
|
||||||
|
authorEmail = authorEmail,
|
||||||
|
authorUrl = authorUrl,
|
||||||
|
content = content,
|
||||||
|
isTest = true), "check_comment -> true")
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
akismet.checkComment(
|
||||||
|
request,
|
||||||
|
permalink = permalink,
|
||||||
|
type = type,
|
||||||
|
author = author,
|
||||||
|
authorEmail = authorEmail,
|
||||||
|
authorUrl = authorUrl,
|
||||||
|
content = content,
|
||||||
|
isTest = true), "check_comment(request) -> true")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun submitHamTest() {
|
||||||
|
assertTrue(
|
||||||
|
akismet.submitHam(
|
||||||
|
userIp = userIp,
|
||||||
|
userAgent = userAgent,
|
||||||
|
referrer = referrer,
|
||||||
|
permalink = permalink,
|
||||||
|
type = type,
|
||||||
|
author = author,
|
||||||
|
authorEmail = authorEmail,
|
||||||
|
authorUrl = authorUrl,
|
||||||
|
content = content,
|
||||||
|
isTest = true), "submitHam")
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
akismet.submitHam(
|
||||||
|
request,
|
||||||
|
permalink = permalink,
|
||||||
|
type = type,
|
||||||
|
author = author,
|
||||||
|
authorEmail = authorEmail,
|
||||||
|
authorUrl = authorUrl,
|
||||||
|
content = content,
|
||||||
|
isTest = true), "submitHam(request)")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun submitSpamTest() {
|
||||||
|
assertTrue(
|
||||||
|
akismet.submitSpam(
|
||||||
|
userIp = userIp,
|
||||||
|
userAgent = userAgent,
|
||||||
|
referrer = referrer,
|
||||||
|
permalink = permalink,
|
||||||
|
type = type,
|
||||||
|
author = author,
|
||||||
|
authorEmail = authorEmail,
|
||||||
|
authorUrl = authorUrl,
|
||||||
|
content = content,
|
||||||
|
isTest = true), "submitHam")
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
akismet.submitSpam(
|
||||||
|
request,
|
||||||
|
permalink = permalink,
|
||||||
|
type = type,
|
||||||
|
author = author,
|
||||||
|
authorEmail = authorEmail,
|
||||||
|
authorUrl = authorUrl,
|
||||||
|
content = content,
|
||||||
|
isTest = true), "submitHam(request)")
|
||||||
|
}
|
||||||
|
|
||||||
assertTrue(akismet.checkComment(request,
|
|
||||||
permalink = permalink,
|
|
||||||
type = type,
|
|
||||||
author = author,
|
|
||||||
authorEmail = authorEmail,
|
|
||||||
authorUrl = authorUrl,
|
|
||||||
content = content,
|
|
||||||
isTest = true), "check_comment(request) -> true")
|
|
||||||
@Test
|
@Test
|
||||||
fun dateToGmtTest() {
|
fun dateToGmtTest() {
|
||||||
val date = Date()
|
val date = Date()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue