Commit 5e58f552 authored by Philip Cunningham's avatar Philip Cunningham

Strip trailing whitespace from validation response

Strips trailing whitespace before checking site validation.
parent 93c2848c
...@@ -41,7 +41,7 @@ module DastSiteValidations ...@@ -41,7 +41,7 @@ module DastSiteValidations
case dast_site_validation.validation_strategy case dast_site_validation.validation_strategy
when 'text_file' when 'text_file'
response.content_type == 'text/plain' && response.body == token response.content_type == 'text/plain' && response.body.rstrip == token
when 'header' when 'header'
response.headers[DastSiteValidation::HEADER] == token response.headers[DastSiteValidation::HEADER] == token
else else
......
---
title: Strip trailing whitespace from DAST site validation HTTP response body
merge_request: 53951
author:
type: changed
...@@ -129,6 +129,14 @@ RSpec.describe DastSiteValidations::ValidateService do ...@@ -129,6 +129,14 @@ RSpec.describe DastSiteValidations::ValidateService do
it_behaves_like 'a validation' it_behaves_like 'a validation'
context 'when the http response body has trailing newlines after the token' do
let(:token) { dast_site_validation.dast_site_token.token + "\n\n" }
it 'does not raise an exception' do
expect { subject }.not_to raise_error(DastSiteValidations::ValidateService::TokenNotFound)
end
end
context 'when content type is incorrect' do context 'when content type is incorrect' do
let(:headers) { { 'Content-Type' => 'text/html; charset=UTF-8' } } let(:headers) { { 'Content-Type' => 'text/html; charset=UTF-8' } }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment