'AllureRestAssured , how to ignore logging headers

I am using rest-assured and allureRestAssured for testing api ,

given().header("Content-Type", "application/json")
                .header("key", key()).filter(new AllureRestAssured())
                .body(body.toString())
                .post(baseURI);

Problem here is its logged headers also , which contains auth key , which I dont want to be exposed in report generated , how can I ignore that .



Solution 1:[1]

You can extend the AllureRestAssured filter and override it. There is the private method toMapConverter I add it to my implementation. I just remove by Key what I don't want to show in the report.

    private static Map<String, String> toMapConverter(final Iterable<? extends NameAndValue> items) {
    final Map<String, String> result = new HashMap<>();
    items.forEach(h -> result.put(h.getName(), h.getValue()));
    result.remove("key");
    return result;
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Igor Nosovsky