Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Grahame Grieve committed Dec 30, 2023
1 parent 3017bbd commit fbd42bd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
44 changes: 25 additions & 19 deletions library/fsl/tests/fsl_tests.pas
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@
interface

Uses
{$IFDEF WINDOWS} Windows, {$ENDIF} SysUtils, Classes, {$IFNDEF FPC}Soap.EncdDecd, System.NetEncoding, {$ENDIF} SyncObjs, zlib,
{$IFDEF WINDOWS} Windows, {$ENDIF} SysUtils, Classes, {$IFNDEF FPC}Soap.EncdDecd, System.NetEncoding, {$ENDIF} SyncObjs,
zlib, zstream,
{$IFDEF FPC} FPCUnit, TestRegistry, RegExpr, {$ELSE} TestFramework, {$ENDIF} fsl_testing,
IdGlobalProtocols,
fsl_base, fsl_utilities, fsl_stream, fsl_threads, fsl_collections, fsl_fpc, fsl_versions,
fsl_xml,
{$IFNDEF FPC}
fsl_msxml,
{$ENDIF}
fsl_json, fsl_turtle, fsl_comparisons;
fsl_json, fsl_turtle, fsl_comparisons, fsl_npm;

Type
TFslTestString = class (TFslObject)
Expand Down Expand Up @@ -5264,39 +5265,44 @@ procedure TXmlUtilsTest.TestUnPretty;

function TTarGZParserTests.load(filename : String) : TFslList<TFslNameBuffer>;
var
bs : TBytesStream;
z : TZDecompressionStream;
tar : TTarArchive;
entry : TTarDirRec;
mem : TMemoryStream;
n : String;
b : TBytes;
bi : TBytesStream;
item : TFslNameBuffer;
stream : TFileStream;
begin
begin
result := TFslList<TFslNameBuffer>.Create;
try
stream := TFileStream.Create(filename, fmOpenRead);
bs := TBytesStream.create(readZLibHeader(TFileStream.create(filename, fmOpenRead)));
try
z := TZDecompressionStream.Create(stream, false); // 15+16);
z := TZDecompressionStream.Create(bs, true); // 15+16);
try
tar := TTarArchive.Create(z);
try
tar.Reset;
while tar.FindNext(entry) do
begin
n := String(entry.Name);
if (n.contains('..')) then
raise EFSLException.create('The package contains the file "'+n+'". Packages are not allowed to contain files with ".." in the name');
bi := TBytesStream.Create;
try
tar.ReadFile(bi);
b := copy(bi.Bytes, 0, bi.size);
finally
bi.free;
end;
item := TFslNameBuffer.Create;
try
item.Name := String(entry.Name);
mem := TMemoryStream.Create;
try
tar.ReadFile(mem);
mem.position := 0;
item.loadFromStream(mem);
finally
mem.free;
end;
item.Name := n;
item.AsBytes := b;
result.Add(item.link)
finally
item.free;
end;
//break;
end;
finally
tar.free;
Expand All @@ -5305,8 +5311,8 @@ function TTarGZParserTests.load(filename : String) : TFslList<TFslNameBuffer>;
z.free;
end;
finally
stream.free;
end;
bs.free;
end;
result.link;
finally
result.free;
Expand Down
1 change: 0 additions & 1 deletion library/fsl/tests/fsl_tests_web.pas
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ procedure TOpenSSLTests.testWebServer_110;
begin
assertTrue(TestSettings.SSLCertFile <> '', 'Must provide public key file for SSL test in '+TestSettings.filename+' ([ssl] cert=)');
assertTrue(TestSettings.SSLKeyFile <> '', 'Must provide private key file for SSL test in '+TestSettings.filename+' ([ssl] key=)');
assertTrue(TestSettings.SSLPassword <> '', 'Must provide password for private key for SSL test in '+TestSettings.filename+' ([ssl] password=)');
assertTrue(TestSettings.SSLCAFile <> '', 'Must provide ca cert file for SSL test in '+TestSettings.filename+' ([ssl] cacert=)');

assertTrue(FileExists(TestSettings.SSLCertFile), 'SSL Certificate not found at '+TestSettings.SSLCertFile);
Expand Down

0 comments on commit fbd42bd

Please sign in to comment.