Skip to content

Commit 31b0cab

Browse files
committed
tests for the 4 new oracles
1 parent d8ba486 commit 31b0cab

3 files changed

Lines changed: 33 additions & 4 deletions

File tree

  • core-tests/e2e-tests/spring/spring-rest-openapi-v3/src
  • core/src/main/kotlin/org/evomaster/core/problem/rest/oracle

core-tests/e2e-tests/spring/spring-rest-openapi-v3/src/main/kotlin/com/foo/rest/examples/spring/openapi/v3/statusoracle/StatusOracleRest.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,19 @@ private class StatisticsRest {
8080
return ResponseEntity.status(403).build()
8181
}
8282

83+
84+
@PostMapping(path = ["/no-304-if-no-get-or-head"])
85+
fun no304IfNoGetOrHead(): ResponseEntity<String>{
86+
return ResponseEntity.status(304).build()
87+
}
88+
89+
@GetMapping(path = ["/no-405-if-no-allow"])
90+
fun no405IfNoAllow(): ResponseEntity<String>{
91+
return ResponseEntity.status(405).build()
92+
}
93+
94+
@GetMapping(path = ["/no-501-if-implemented"])
95+
fun no501IfImplemented(): ResponseEntity<String>{
96+
return ResponseEntity.status(501).build()
97+
}
8398
}

core-tests/e2e-tests/spring/spring-rest-openapi-v3/src/test/kotlin/org/evomaster/e2etests/spring/openapi/v3/statusoracle/StatusOracleEMTest.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import org.junit.jupiter.api.Assertions
99
import org.junit.jupiter.api.Assertions.assertTrue
1010
import org.junit.jupiter.api.BeforeAll
1111
import org.junit.jupiter.api.Test
12+
import javax.ws.rs.POST
1213

1314
class StatusOracleEMTest : SpringTestBase(){
1415

@@ -57,11 +58,20 @@ class StatusOracleEMTest : SpringTestBase(){
5758
//assertHasAtLeastOne(solution, HttpVerb.GET, 204, "/api/statusoracle/no-204-if-content", "Hello")
5859
//assertTrue(faultsCategories.any { it == ExperimentalFaultCategory.HTTP_STATUS_NO_204_IF_CONTENT })
5960

61+
//304
62+
assertHasAtLeastOne(solution, HttpVerb.POST, 304, "/api/statusoracle/no-304-if-no-get-or-head", null)
63+
assertTrue(faultsCategories.any { it == ExperimentalFaultCategory.HTTP_STATUS_NO_304_IF_NO_GET_OR_HEAD })
64+
6065
//401 and 403
6166
assertHasAtLeastOne(solution, HttpVerb.GET, 401, "/api/statusoracle/no-401-if-no-auth", null)
6267
assertHasAtLeastOne(solution, HttpVerb.GET, 403, "/api/statusoracle/no-403-if-no-401", null)
6368
assertTrue(faultsCategories.any { it == ExperimentalFaultCategory.HTTP_STATUS_NO_401_IF_NO_AUTH })
6469
assertTrue(faultsCategories.any { it == ExperimentalFaultCategory.HTTP_STATUS_NO_403_IF_NO_401 })
70+
assertTrue(faultsCategories.any { it == ExperimentalFaultCategory.HTTP_STATUS_NO_401_IF_NO_WWW_AUTHENTICATE })
71+
72+
//405
73+
assertHasAtLeastOne(solution, HttpVerb.GET, 405, "/api/statusoracle/no-405-if-no-allow", null)
74+
assertTrue(faultsCategories.any{ it == ExperimentalFaultCategory.HTTP_STATUS_NO_405_IF_NO_ALLOW})
6575

6676
//406
6777
assertHasAtLeastOne(solution, HttpVerb.POST, 406, "/api/statusoracle/has-406-if-accept", null)
@@ -72,6 +82,10 @@ class StatusOracleEMTest : SpringTestBase(){
7282
assertHasAtLeastOne(solution, HttpVerb.POST, 415, "/api/statusoracle/no-415-if-no-payload", null)
7383
assertTrue(faultsCategories.any { it == ExperimentalFaultCategory.HTTP_STATUS_NO_413_IF_NO_PAYLOAD })
7484
assertTrue(faultsCategories.any { it == ExperimentalFaultCategory.HTTP_STATUS_NO_415_IF_NO_PAYLOAD })
85+
86+
//501
87+
assertHasAtLeastOne(solution, HttpVerb.GET, 501, "/api/statusoracle/no-501-if-implemented", null)
88+
assertTrue(faultsCategories.any { it == ExperimentalFaultCategory.HTTP_STATUS_NO_501_IF_IMPLEMENTED })
7589
}
7690
}
7791
}

core/src/main/kotlin/org/evomaster/core/problem/rest/oracle/HttpStatusOracle.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import org.evomaster.core.problem.rest.schema.SchemaUtils
2424
* no-201-if-get
2525
* no-201-if-patch
2626
* no-204-if-content
27-
* no-304-if-no-get-or-head (TODO)
28-
* no-401-if-no-www-authenticate (TODO)
29-
* no-405-if-no-allow (TODO)
27+
* no-304-if-no-get-or-head
28+
* no-401-if-no-www-authenticate
29+
* no-405-if-no-allow
3030
* no-413-if-no-payload
3131
* no-415-if-no-payload
3232
* no-401-if-no-auth (schema)
3333
* no-403-if-no-401 (schema)
3434
* has-406-if-accept (schema)
35-
* no-501-if-implemented (TODO)
35+
* no-501-if-implemented
3636
*
3737
*
3838
* IMPORTANT: in contrast to what done in [HttpSemanticsOracle], here there is no need to construct any test case

0 commit comments

Comments
 (0)