Skip to content

Commit 6edbf61

Browse files
authored
Merge pull request #1166 from WebFuzzing/issue-1159
#1159: better error message if issues in em.yaml
2 parents a694858 + 1c35b48 commit 6edbf61

File tree

4 files changed

+71
-3
lines changed

4 files changed

+71
-3
lines changed

core/src/main/kotlin/org/evomaster/core/EMConfig.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,16 @@ class EMConfig {
355355
LoggingUtil.uniqueUserInfo("Loading configuration file from: ${Path(configPath).toAbsolutePath()}")
356356
}
357357

358-
val cf = ConfigUtil.readFromFile(configPath)
359-
cf.validateAndNormalizeAuth()
360-
return cf
358+
try {
359+
val cf = ConfigUtil.readFromFile(configPath)
360+
cf.validateAndNormalizeAuth()
361+
return cf
362+
}catch (e: Exception){
363+
val cause = if(e.cause!=null) "\nCause:${e.cause!!.message}" else ""
364+
throw ConfigProblemException("Failed when reading configuration file at $configPath." +
365+
"\nError: ${e.message}" +
366+
"$cause")
367+
}
361368
}
362369

363370
private fun applyConfigFromFile(cff: ConfigsFromFile) {

core/src/test/kotlin/org/evomaster/core/config/ConfigUtilTest.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,14 @@ class ConfigUtilTest{
8080
assertTrue(config.auth.any { it.loginEndpointAuth.payloadUserPwd == null && it.loginEndpointAuth.payloadRaw != null})
8181
assertTrue(config.auth.any { it.loginEndpointAuth.payloadUserPwd != null && it.loginEndpointAuth.payloadRaw == null})
8282
}
83+
84+
85+
@Test
86+
fun testIssue1159(){
87+
88+
val path = "${basePath}/issue1159.yaml"
89+
org.junit.jupiter.api.assertThrows<IllegalArgumentException> {
90+
val config = ConfigUtil.readFromFile(path)
91+
}
92+
}
8393
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#https://github.com/WebFuzzing/EvoMaster/issues/1159
2+
3+
configs: # remove this {} when specifying properties
4+
bbSwaggerUrl: "http://obedocumentation.fwh.is/?i=1"
5+
bbTargetUrl: "http://obedocumentation.fwh.is/?i=1"
6+
blackBox: true
7+
configPath: "em.yaml"
8+
endpointFocus: null
9+
endpointPrefix: null
10+
endpointTagFilter: null
11+
# header0: ""
12+
# header1: ""
13+
# header2: ""
14+
maxTime: "60s"
15+
outputFilePrefix: "EvoMaster"
16+
outputFileSuffix: "Test"
17+
outputFolder: "generated_tests"
18+
outputFormat: "DEFAULT"
19+
prematureStop: ""
20+
ratePerMinute: 0
21+
sutControllerHost: "localhost"
22+
sutControllerPort: 40100
23+
testTimeout: 60
24+
25+
26+
auth:
27+
- name: i gede
28+
loginEndpointAuth:
29+
payloadRaw: "{\"email\": \"[email protected]\", \"password\": \"sainsdata\"}"
30+
- name: susrama
31+
loginEndpointAuth:
32+
payloadUserPwd:
33+
34+
password: "sainsdata"
35+
usernameField: email
36+
passwordField: password
37+
token:
38+
headerPrefix: "Bearer "
39+
extractFromField: "/token/authToken"
40+
httpHeaderName: "Authorization"
41+
42+
authTemplate:
43+
loginEndpointAuth:
44+
endpoint: /login
45+
verb: POST
46+
contentType: application/json
47+
expectCookies: true

release_notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Under development in `master` branch.
55
### New Features
66
- Support for object in example/examples in OpenAPI schemas.
77

8+
### Addressed GitHub Issues
9+
- #1159: EvoMaster crashed when reading em.yaml file
10+
11+
812

913
# Version: 3.4.0
1014

0 commit comments

Comments
 (0)