use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class VariantHeaderUnitTest method shouldNotExtractAnyParameterIfThereAreNoHeaders.
@Test
void shouldNotExtractAnyParameterIfThereAreNoHeaders() {
// Given
VariantHeader variantHeader = new VariantHeader();
HttpMessage messageWithHeaders = createMessageWithoutInjectableHeaders();
// When
variantHeader.setMessage(messageWithHeaders);
// Then
assertThat(variantHeader.getParamList(), is(empty()));
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class VariantHeaderUnitTest method shouldIgnoreChangesToHeaderName.
@Test
void shouldIgnoreChangesToHeaderName() {
// Given
VariantHeader variantHeader = new VariantHeader();
HttpMessage message = createMessageWithHeaders(header("X-Header-A", "X"), header("X-Header-B", "Y"), header("X-Header-C", "Z"));
variantHeader.setMessage(message);
// When
String injectedHeader = variantHeader.setParameter(message, header("X-Header-A", "X", 0), "X-Header-Z", "X");
// Then
assertThat(injectedHeader, is(equalTo("X-Header-A: X")));
assertThat(message, containsHeader("X-Header-A", "X"));
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class VariantMultipartFormParametersUnitTest method shouldInjectParamValueModificationInGeneralParam.
@Test
void shouldInjectParamValueModificationInGeneralParam() {
// Given
VariantMultipartFormParameters variant = new VariantMultipartFormParameters();
HttpMessage message = createMessage();
String paramName = "person";
String newValue = "injected";
variant.setMessage(message);
// When
variant.setParameter(message, new NameValuePair(NameValuePair.TYPE_MULTIPART_DATA_PARAM, paramName, DEFAULT_PARAM_CONTENT, 1), paramName, newValue);
HttpMessage newMsg = createMessage(newValue, DEFAULT_FILE_NAME, DEFAULT_CONTENT_TYPE, DEFAULT_FILE_PARAM_CONTENT);
// Then
assertThat(message.getRequestBody().toString(), equalTo(newMsg.getRequestBody().toString()));
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class VariantMultipartFormParametersUnitTest method shouldInjectParamValueMultipleTimesModificationInFileNameParam.
@Test
void shouldInjectParamValueMultipleTimesModificationInFileNameParam() {
// Given
VariantMultipartFormParameters variant = new VariantMultipartFormParameters();
HttpMessage message = createMessage();
String paramName = "somefile";
String newValue = "somefile9";
variant.setMessage(message);
// When
InputVectorBuilder inputVectorBuilder = new InputVectorBuilder();
for (int i = 0; i < 10; i++) {
inputVectorBuilder.setNameAndValue(new NameValuePair(NameValuePair.TYPE_MULTIPART_DATA_FILE_NAME, paramName, DEFAULT_FILE_NAME, 2), paramName, PayloadFormat.ALREADY_ESCAPED, newValue, PayloadFormat.ALREADY_ESCAPED);
}
variant.setParameters(message, inputVectorBuilder.build());
HttpMessage newMsg = createMessage(DEFAULT_PARAM_CONTENT, newValue, DEFAULT_CONTENT_TYPE, DEFAULT_FILE_PARAM_CONTENT);
// Then
assertThat(message.getRequestBody().toString(), equalTo(newMsg.getRequestBody().toString()));
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class VariantMultipartFormParametersUnitTest method shouldInjectParamValueModificationInFileParam.
@Test
void shouldInjectParamValueModificationInFileParam() {
// Given
VariantMultipartFormParameters variant = new VariantMultipartFormParameters();
HttpMessage message = createMessage();
String paramName = "somefile";
String newValue = "injected";
String origValue = "contents of the file";
variant.setMessage(message);
// When
variant.setParameter(message, new NameValuePair(NameValuePair.TYPE_MULTIPART_DATA_FILE_PARAM, paramName, origValue, 4), paramName, newValue);
HttpMessage newMsg = createMessage(DEFAULT_PARAM_CONTENT, DEFAULT_FILE_NAME, DEFAULT_CONTENT_TYPE, newValue);
// Then
assertThat(message.getRequestBody().toString(), equalTo(newMsg.getRequestBody().toString()));
}
Aggregations