Skip to content

Conversation

@omursahin
Copy link
Collaborator

No description provided.

@omursahin
Copy link
Collaborator Author

/**
* Calls:
* 1 - (201) PUT:/api/parents/{pid}
* 2 - (201) PUT:/api/parents/{pid}/children/{cid}
* 3 - (403) GET:/api/parents/{pid}/children/{cid}
* 4 - (404) GET:/api/parents/{pid}/children/{cid}
* 5 - (403) GET:/api/parents/{pid}
* Found 1 potential fault of type-code 204
*/
@Test @Timeout(60)
fun test_4_getOnParentAllowsUnauthorizedAccessToProtectedResource()  {
    
    val res_0: ValidatableResponse = given().accept("*/*")
            .header("Authorization", "BAR") // BAR
            .header("x-EMextraHeader123", "42")
            .put("${baseUrlOfSut}/api/parents/996")
            .then()
            .statusCode(201)
            .assertThat()
            .body(isEmptyOrNullString())
    val location_pid__2 = res_0.extract().header("location")
    assertTrue(isValidURIorEmpty(location_pid__2));
    
    given().accept("*/*")
            .header("Authorization", "BAR") // BAR
            .header("x-EMextraHeader123", "")
            .put(resolveLocation(location_pid__2, baseUrlOfSut + "/api/parents/996/children/877?EMextraParam123=42"))
            .then()
            .statusCode(201)
            .assertThat()
            .body(isEmptyOrNullString())
    
    given().accept("*/*")
            .header("Authorization", "FOO") // FOO
            .header("x-EMextraHeader123", "42")
            .get("${baseUrlOfSut}/api/parents/996/children/877")
            .then()
            .statusCode(403)
            .assertThat()
            .body(isEmptyOrNullString())
    
    // Fault204. Leakage Information Existence of Protected Resource. null.
    given().accept("*/*")
            .header("Authorization", "BAR") // BAR
            .header("x-EMextraHeader123", "")
            .get("${baseUrlOfSut}/api/parents/132/children/845")
            .then()
            .statusCode(404)
            .assertThat()
            .body(isEmptyOrNullString())
    
    given().accept("*/*")
            .header("Authorization", "BAR") // BAR
            .header("x-EMextraHeader123", "42")
            .get("${baseUrlOfSut}/api/parents/132?EMextraParam123=42")
            .then()
            .statusCode(403)
            .assertThat()
            .body(isEmptyOrNullString())
}

@omursahin omursahin requested a review from arcuri82 January 15, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants