Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set multiple log config in RequestSpecBuilder #1783

Open
itkhanz opened this issue Apr 23, 2024 · 0 comments
Open

Cannot set multiple log config in RequestSpecBuilder #1783

itkhanz opened this issue Apr 23, 2024 · 0 comments

Comments

@itkhanz
Copy link

itkhanz commented Apr 23, 2024

Hi,
I am trying to log the request and response if validation fails, but at the same time I also want to filter out or blacklist one of my response headers. I am setting this configuration in RequestSpecBuilder but it does not blacklist the response header and instead logs the whole response.

Here is how the code looks:

PreemptiveBasicAuthScheme basicAuthScheme = new PreemptiveBasicAuthScheme();
basicAuthScheme.setUserName(System.getProperty("user"));
basicAuthScheme.setPassword(System.getProperty("password"));

RequestSpecBuilder requestSpecBuilder = new RequestSpecBuilder();
requestSpecBuilder.setAuth(basicAuthScheme);
requestSpecBuilder.setConfig(RestAssuredConfig.config()
                .logConfig(new LogConfig()
                        .enableLoggingOfRequestAndResponseIfValidationFails(LogDetail.ALL)
                        .and()
                        .blacklistHeader("X-AUSERNAME")
                        .and()
                        .blacklistDefaultSensitiveHeaders()
                )
        );

Background:

I am using PreemptiveBasicAuthScheme to set my username and password, and I do not want the username or password to get logged in response. Currently REST Assured logs the username in response header with key X-AUSERNAME which I am trying to blacklist. Is there a way to filter this from response header when logging only if validation fails?

I would appreciate any help in this regard.

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

No branches or pull requests

1 participant