mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
This commit is contained in:
parent
ac9f3bc7f6
commit
ab2c92c26f
@ -113,7 +113,7 @@ type
|
||||
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
|
||||
|
@ -100,6 +100,8 @@ type
|
||||
[Test]
|
||||
procedure TestComplexRoutings;
|
||||
[Test]
|
||||
procedure TestIssue338;
|
||||
[Test]
|
||||
procedure TestProduceRoutings;
|
||||
[Test]
|
||||
procedure TestProduceRoutingsWithExplicitCharset;
|
||||
@ -204,16 +206,13 @@ uses System.DateUtils, System.Math,
|
||||
MVCFramework.Serializer.Commons,
|
||||
MVCFramework.HMAC, System.Diagnostics,
|
||||
|
||||
{$IF CompilerVersion < 27}
|
||||
|
||||
{$IF CompilerVersion < 27}
|
||||
Data.DBXJSON,
|
||||
|
||||
{$ELSE}
|
||||
|
||||
{$ELSE}
|
||||
System.JSON,
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
{$ENDIF}
|
||||
TestServerControllerU, System.Classes,
|
||||
MVCFramework.DuckTyping, System.IOUtils, MVCFramework.SystemJSONUtils,
|
||||
IdGlobal;
|
||||
@ -440,6 +439,36 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestRouting.TestIssue338;
|
||||
var
|
||||
Params: TMVCRequestParamsTable;
|
||||
ResponseContentType: string;
|
||||
ResponseContentEncoding: string;
|
||||
begin
|
||||
// https://github.com/danieleteti/delphimvcframework/issues/338
|
||||
Params := TMVCRequestParamsTable.Create;
|
||||
try
|
||||
Params.Clear;
|
||||
Assert.isTrue(FRouter.ExecuteRouting('/projectid/pictures/imageuuid', httpGET,
|
||||
'text/plain', 'text/plain', FControllers, 'text/plain', TMVCMediaType.TEXT_PLAIN, Params,
|
||||
ResponseContentType, ResponseContentEncoding));
|
||||
Assert.areEqual('GetImage', FRouter.MethodToCall.Name);
|
||||
Assert.areEqual(2, Params.Count);
|
||||
Assert.areEqual('projectid', Params['projectid']);
|
||||
Assert.areEqual('imageuuid', Params['imageuuid']);
|
||||
|
||||
Params.Clear;
|
||||
Assert.isTrue(FRouter.ExecuteRouting('/projectid', httpGET,
|
||||
'text/plain', 'text/plain', FControllers, 'text/plain', TMVCMediaType.TEXT_PLAIN, Params,
|
||||
ResponseContentType, ResponseContentEncoding));
|
||||
Assert.areEqual('GetProject', FRouter.MethodToCall.Name);
|
||||
Assert.areEqual(1, Params.Count);
|
||||
Assert.areEqual('projectid', Params['projectid']);
|
||||
finally
|
||||
Params.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
// procedure TTestMappers.TestDataSetToJSONArray;
|
||||
// var
|
||||
// ds: TClientDataSet;
|
||||
@ -1139,8 +1168,8 @@ begin
|
||||
// this test just tests the IP2Long implementation
|
||||
for I := low(RESERVED_IPS) to high(RESERVED_IPS) do
|
||||
begin
|
||||
Assert.AreEqual(IPv4ToUInt32(RESERVED_IPS[I][1]), IP2Long(RESERVED_IPS[I][1]));
|
||||
Assert.AreEqual(IPv4ToUInt32(RESERVED_IPS[I][2]), IP2Long(RESERVED_IPS[I][2]));
|
||||
Assert.areEqual(IPv4ToUInt32(RESERVED_IPS[I][1]), IP2Long(RESERVED_IPS[I][1]));
|
||||
Assert.areEqual(IPv4ToUInt32(RESERVED_IPS[I][2]), IP2Long(RESERVED_IPS[I][2]));
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -66,8 +66,8 @@ type
|
||||
|
||||
public
|
||||
[Test]
|
||||
[TestCase('request url /fault', '/fault')]
|
||||
[TestCase('request url /fault2', '/fault2')]
|
||||
[TestCase('request url /fault', '/exception/fault')]
|
||||
[TestCase('request url /fault2', '/exception/fault2')]
|
||||
procedure TestControllerWithExceptionInCreate(const URLSegment: string);
|
||||
|
||||
[Test]
|
||||
@ -1537,7 +1537,7 @@ begin
|
||||
lValues[3] := '"daniele teti"';
|
||||
lValues[4] := '"daniele" "teti"';
|
||||
lValues[5] := '"daniele" "teti"!';
|
||||
lValues[6] := ' _\"daniele" "teti"!/_ ';
|
||||
lValues[6] := ' _\"daniele" "teti"!_ ';
|
||||
|
||||
for s in lValues do
|
||||
begin
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Delphi MVC Framework
|
||||
//
|
||||
// Copyright (c) 2010-2017 Daniele Teti and the DMVCFramework Team
|
||||
// Copyright (c) 2010-2020 Daniele Teti and the DMVCFramework Team
|
||||
//
|
||||
// https://github.com/danieleteti/delphimvcframework
|
||||
//
|
||||
@ -69,7 +69,7 @@ type
|
||||
|
||||
[Headers('Accept', 'application/json')]
|
||||
[Headers('ContentType', 'application/json')]
|
||||
[RESTResource(HttpGet, '/testconsumejson')]
|
||||
[RESTResource(HttpGet, '/adapter/testconsumejson')]
|
||||
function HeadersApplicationJSON: TJSONValue;
|
||||
|
||||
[Headers('Accept', 'text/plain')]
|
||||
@ -79,7 +79,7 @@ type
|
||||
|
||||
[Headers('Accept', 'text/plain')]
|
||||
[Headers('ContentType', 'text/plain')]
|
||||
[RESTResource(HttpGet, '/testconsumejson')]
|
||||
[RESTResource(HttpGet, '/adapter/testconsumejson')]
|
||||
function ApplicationJSONWithTextPlainHeader: IRESTResponse;
|
||||
|
||||
end;
|
||||
|
@ -97,7 +97,7 @@ type
|
||||
[MVCProduces('text/plain', 'utf-8')]
|
||||
procedure TestConsumesProducesText;
|
||||
|
||||
[MVCPath('/testconsumejson')]
|
||||
[MVCPath('/adapter/testconsumejson')]
|
||||
[MVCHTTPMethod([httpGET])]
|
||||
[MVCConsumes('application/json')]
|
||||
[MVCProduces('application/json', 'utf-8')]
|
||||
@ -221,6 +221,14 @@ type
|
||||
[MVCHTTPMethod([httpGET])]
|
||||
[MVCPath('/responses/nocontent')]
|
||||
procedure TestResponseNoContent;
|
||||
|
||||
[MVCHTTPMethod([httpGET])]
|
||||
[MVCPath('/($projectid)')]
|
||||
procedure GetProject;
|
||||
|
||||
[MVCHTTPMethod([httpGET])]
|
||||
[MVCPath('/($projectid)/pictures/($imageuuid)')]
|
||||
procedure GetImage;
|
||||
end;
|
||||
|
||||
[MVCPath('/private')]
|
||||
@ -235,7 +243,7 @@ type
|
||||
procedure OnlyRole2;
|
||||
end;
|
||||
|
||||
[MVCPath('/fault')]
|
||||
[MVCPath('/exception/fault')]
|
||||
TTestFaultController = class(TMVCController)
|
||||
public
|
||||
[MVCPath]
|
||||
@ -243,7 +251,7 @@ type
|
||||
constructor Create; override;
|
||||
end;
|
||||
|
||||
[MVCPath('/fault2')]
|
||||
[MVCPath('/exception/fault2')]
|
||||
TTestFault2Controller = class(TTestFaultController)
|
||||
public
|
||||
[MVCPath]
|
||||
@ -340,6 +348,16 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TTestServerController.GetImage;
|
||||
begin
|
||||
// do nothing
|
||||
end;
|
||||
|
||||
procedure TTestServerController.GetProject;
|
||||
begin
|
||||
// do nothing
|
||||
end;
|
||||
|
||||
procedure TTestServerController.Login;
|
||||
begin
|
||||
if Context.SessionStarted then
|
||||
|
Loading…
Reference in New Issue
Block a user