Skip to content

Commit

Permalink
Added more characters in URL_MAPPED_PARAMS_ALLOWED_CHARS = ' àèéùòì''…
Browse files Browse the repository at this point in the history
…"@\[\]\{\}\(\)\=;&#\.:!\_\/,%\w\d\x2D\x3A';

Added more unit tests
  • Loading branch information
danieleteti committed Mar 4, 2020
1 parent cb46414 commit f99aa89
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sources/MVCFramework.Commons.pas
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ TMVCConstants = record
LAST_AUTHORIZATION_HEADER_VALUE = '__DMVC_LAST_AUTHORIZATION_HEADER_VALUE_';
SSE_RETRY_DEFAULT = 100;
SSE_LAST_EVENT_ID = 'Last-Event-ID';
URL_MAPPED_PARAMS_ALLOWED_CHARS = ' àèéùòì@\[\]\{\}\(\)\=;&#\.\_\,%\w\d\x2D\x3A';
URL_MAPPED_PARAMS_ALLOWED_CHARS = ' àèéùòì''"@\[\]\{\}\(\)\=;&#\.:!\_\/,%\w\d\x2D\x3A';
OneMiB = 1048576;
OneKiB = 1024;
DEFAULT_MAX_REQUEST_SIZE = OneMiB * 5; // 5 MiB
Expand Down
44 changes: 41 additions & 3 deletions unittests/general/Several/LiveServerTestU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1527,10 +1527,48 @@ procedure TServerTest.TestTypedSingle1;
procedure TServerTest.TestTypedString1;
var
res: IRESTResponse;
lValues: array [0..7] of string;
s: string;
begin
res := RESTClient.doGET('/typed/string1/daniele', []);
Assert.isTrue(res.ResponseCode = HTTP_STATUS.OK, 'Cannot route');
Assert.areEqual('daniele modified from server', res.BodyAsString);
lValues[0] := 'daniele';
lValues[1] := 'dan''iele';
lValues[2] := '"daniele"';
lValues[3] := '"daniele teti"';
lValues[4] := '"daniele" "teti"';
lValues[5] := '"daniele" "teti"!';
lValues[6] := ' _\"daniele" "teti"!/_ ';

for s in lValues do
begin
res := RESTClient.doGET('/typed/string1', [s]);
Assert.AreEqual(HTTP_STATUS.OK, res.ResponseCode, 'Cannot route when param is ' + s);
Assert.areEqual('*' + s + '*', res.BodyAsString);
end;

// res := RESTClient.doGET('/typed/string1/daniele', []);
// Assert.isTrue(res.ResponseCode = HTTP_STATUS.OK, 'Cannot route');
// Assert.areEqual('daniele modified from server', res.BodyAsString);
//
// res := RESTClient.doGET('/typed/string1/dan''iele', []);
// Assert.isTrue(res.ResponseCode = HTTP_STATUS.OK, 'Cannot route');
// Assert.areEqual('dan''iele modified from server', res.BodyAsString);
//
// res := RESTClient.doGET('/typed/string1/"the value"', []);
// Assert.isTrue(res.ResponseCode = HTTP_STATUS.OK, 'Cannot route');
// Assert.areEqual('"the value" modified from server', res.BodyAsString);
//
// res := RESTClient.doGET('/typed/string1/"the:value"', []);
// Assert.isTrue(res.ResponseCode = HTTP_STATUS.OK, 'Cannot route');
// Assert.areEqual('"the value" modified from server', res.BodyAsString);
//
// res := RESTClient.doGET('/typed/string1/"the:value!"', []);
// Assert.isTrue(res.ResponseCode = HTTP_STATUS.OK, 'Cannot route');
// Assert.areEqual('"the value" modified from server', res.BodyAsString);
//
// res := RESTClient.doGET('/typed/string1/"the:value!?"', []);
// Assert.isTrue(res.ResponseCode = HTTP_STATUS.OK, 'Cannot route');
// Assert.areEqual('"the value" modified from server', res.BodyAsString);

end;

procedure TServerTest.TestWrongJSONBody;
Expand Down
2 changes: 1 addition & 1 deletion unittests/general/TestServer/TestServerControllerU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ procedure TTestServerController.TestTypedActionInteger1(value: Integer);
procedure TTestServerController.TestTypedActionString1(value: string);
begin
ContentType := TMVCMediaType.TEXT_PLAIN;
Render(value + ' modified from server');
Render('*' + value + '*');
end;

procedure TTestServerController.TestTypedActionTDate1(value: TDate);
Expand Down

0 comments on commit f99aa89

Please sign in to comment.