Skip to content

Commit

Permalink
flag requireMockHandling in auth
Browse files Browse the repository at this point in the history
  • Loading branch information
arcuri82 committed Mar 27, 2024
1 parent b146420 commit 2f3a7d3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 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 @@ -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 2f3a7d3

Please sign in to comment.