Skip to content

Commit

Permalink
Merge pull request #942 from EMResearch/auth-mock-flag
Browse files Browse the repository at this point in the history
Auth mock flag
  • Loading branch information
arcuri82 authored Mar 28, 2024
2 parents b146420 + 7a7c238 commit bdf239f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ public class AuthenticationDto {
*/
public String name;

/**
* Specify that the authentication for this user requires setting up mock responses from external services
* in the API.
* This will be done as part of the fuzzing, although only possible for white-box testing.
*
* One consequence here is that, even if we provide correct auth info as input, then a request might still
* fail due to unauthorized access if the fuzzing process does not properly set up these mocked responses in the API itself.
*/
public Boolean requireMockHandling;

/**
* The headers needed for authentication.
* This is used to represent cases in which auth info is static/fixed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ open class HttpWsAuthenticationInfo(
* Represent call done to a login endpoint, from which a token or cookie is extracted
* for auth in following requests.
*/
val endpointCallLogin: EndpointCallLogin?
val endpointCallLogin: EndpointCallLogin?,
val requireMockHandling: Boolean
): AuthenticationInfo(name) {

init {
Expand Down Expand Up @@ -65,7 +66,9 @@ open class HttpWsAuthenticationInfo(
null
}

return HttpWsAuthenticationInfo(dto.name.trim(), headers, endpointCallLogin)
val requireMockHandling = dto.requireMockHandling != null && dto.requireMockHandling

return HttpWsAuthenticationInfo(dto.name.trim(), headers, endpointCallLogin, requireMockHandling)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package org.evomaster.core.problem.httpws.auth
import org.evomaster.core.problem.enterprise.auth.NoAuth


class HttpWsNoAuth : HttpWsAuthenticationInfo("NoAuth", listOf(), null), NoAuth
class HttpWsNoAuth : HttpWsAuthenticationInfo("NoAuth", listOf(), null, false), NoAuth
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ abstract class AbstractRestFitness : HttpWsFitness<RestIndividual>() {
}
}

if (response.status == 401 && a.auth !is NoAuth) {
if (response.status == 401 && a.auth !is NoAuth && !a.auth.requireMockHandling) {
/*
if the endpoint itself is to get auth info, we might exclude auth check for it
eg,
Expand Down

0 comments on commit bdf239f

Please sign in to comment.