11package org.evomaster.core.problem.httpws.service
22
3+ import com.google.inject.Inject
34import com.webfuzzing.commons.auth.Header
45import org.evomaster.client.java.controller.api.dto.auth.AuthenticationDto
56import org.evomaster.client.java.controller.api.dto.SutInfoDto
@@ -12,6 +13,9 @@ import org.evomaster.core.problem.httpws.HttpWsAction
1213import org.evomaster.core.problem.httpws.auth.*
1314import org.evomaster.core.remote.SutProblemException
1415import org.evomaster.core.search.Individual
16+ import org.evomaster.core.search.service.WarningsAggregator
17+ import org.evomaster.core.search.warning.GeneralWarning
18+ import org.evomaster.core.search.warning.WarningCategory
1519import org.slf4j.Logger
1620import org.slf4j.LoggerFactory
1721
@@ -25,6 +29,7 @@ abstract class HttpWsSampler<T> : ApiWsSampler<T>() where T : Individual{
2529 private val log: Logger = LoggerFactory .getLogger(HttpWsSampler ::class .java)
2630 }
2731
32+
2833 // TODO move up to Enterprise
2934 val authentications = AuthSettings ()
3035
@@ -90,27 +95,28 @@ abstract class HttpWsSampler<T> : ApiWsSampler<T>() where T : Individual{
9095 private fun checkAuthSettings (){
9196 val n = authentications.size()
9297 if (n== 0 ){
93- LoggingUtil .uniqueUserWarn(
94- " No authentication info was provided." +
98+ val msg = " No authentication info was provided." +
9599 " Unless you are testing an example API, you should setup some authentication info for different users." +
96100 " If this is the first time you are using EvoMaster, and you just want to get a feeling of how it works," +
97101 " then ignore this warning." +
98102 " However, to get better results, you will need setup authentication info, eventually." +
99- " More info is currently available at " + AnsiColor .inBlue(EM_AUTH_LINK )
100- )
101- }
102- if (n== 1 ){
103+ " More info is currently available at "
104+ LoggingUtil .uniqueUserWarn(msg + AnsiColor .inBlue(EM_AUTH_LINK ))
105+ warningsAggregator.addWarning(GeneralWarning (WarningCategory .FUZZER , msg + EM_AUTH_LINK ))
106+
107+ }else if (n== 1 ){
108+ val msg = " You have provided authentication information only for a single user." +
109+ " Many of the automatic checks done by EvoMaster for access policy validation are based on the" +
110+ " interactions of 2 or more users." +
111+ " To get better results, you are strongly recommended to provide more user authentication info," +
112+ " at the very minimum 2 in total, but better if at least 1 for each different access role you have in your system" +
113+ " that you are testing." +
114+ " More info is currently available at "
115+
103116 // TODO if/when in the future we enable dynamic registration of users, likely we will need to update this
104117 // warning message
105- LoggingUtil .uniqueUserWarn(
106- " You have provided authentication information only for a single user." +
107- " Many of the automatic checks done by EvoMaster for access policy validation are based on the" +
108- " interactions of 2 or more users." +
109- " To get better results, you are strongly recommended to provide more user authentication info," +
110- " at the very minimum 2 in total, but better if at least 1 for each different access role you have in your system" +
111- " that you are testing." +
112- " More info is currently available at " + AnsiColor .inBlue(EM_AUTH_LINK )
113- )
118+ LoggingUtil .uniqueUserWarn(msg + AnsiColor .inBlue(EM_AUTH_LINK ))
119+ warningsAggregator.addWarning(GeneralWarning (WarningCategory .FUZZER , msg + EM_AUTH_LINK ))
114120 }
115121 }
116122
0 commit comments