| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092 |
- { $HDR$}
- {**********************************************************************}
- { Unit archived using Team Coherence }
- { Team Coherence is Copyright 2002 by Quality Software Components }
- { }
- { For further information / comments, visit our WEB site at }
- { http://www.TeamCoherence.com }
- {**********************************************************************}
- {}
- { $Log: 22776: FTPListTests.pas
- {
- { Rev 1.6 10/3/2003 05:47:54 PM JPMugaas
- { OS/2 tests.
- }
- {
- { Rev 1.5 9/28/2003 03:38:54 PM JPMugaas
- { Fixed a bad test case.
- }
- {
- { Rev 1.4 9/28/2003 03:03:22 AM JPMugaas
- { Added tests for nonstandard Unix dates.
- }
- {
- { Rev 1.3 9/27/2003 10:44:58 PM JPMugaas
- { Added a test for MS-DOS formats.
- }
- {
- { Rev 1.2 9/3/2003 07:36:16 PM JPMugaas
- { More parsing test cases.
- }
- {
- { Rev 1.1 9/3/2003 04:01:14 AM JPMugaas
- { Added some preliminary tests.
- }
- {
- { Rev 1.0 9/2/2003 02:27:46 AM JPMugaas
- { Skeliton for new FTP list test. The test is in development now.
- }
- unit FTPListTests;
- interface
- uses
- SysUtils, Classes, BXBubble, BXCategory;
- type
- TFTPTestItem = class(TObject)
- protected
- FTestItem : String;
- FFoundParser : String;
- FExpectedParser : String;
- //note that the Unix servers can normally only report either a year
- //or a time. This can cause ambiguity because the year is interpretted
- //according to the current or previous year if the date has passed or arrived. But
- //because we can't know the local time zone, there can be a 24 hour window
- //of time. E.g. Sept 8 10:00am 2003 can be interpretted as either Sept 8 10:00am 2003 or
- //Sept 8, 2002 if in the window of Sept 7 10:00am or Sept 9 10:00am.
- //Otherwise, a date such as Sept 8: 10:00am can be interpretted differently at different
- //times of the year (when the window period has passed - 2002 or before the window 2003.
- FEvaluateTime : Boolean;
- FEvaluateYear : Boolean;
- //Note that with the BSD -T switch, a time can be returned with seconds
- FFoundYear, FFoundMonth, FFoundDay, FFoundHour, FFoundMin, FFoundSec : Word;
- FExpectedYear, FExpectedMonth, FExpectedDay, FExpectedHour, FExpectedMin, FExpectedSec : Word;
- FFoundOwner : String;
- FExpectedOwner : String;
- FFoundGroup : String;
- FExpectedGroup : String;
- FFoundFileName : String;
- FExpectedFileName : String;
- FFoundFileSize : Integer;
- FExpectedFileSize : Integer;
- public
- procedure Clear;
- property TestItem : String read FTestItem write FTestItem;
- property FoundParser : String read FFoundParser write FFoundParser;
- property ExpectedParser : String read FExpectedParser write FExpectedParser;
- property EvaluateTime : Boolean read FEvaluateTime write FEvaluateTime;
- property EvaluateYear : Boolean read FEvaluateYear write FEvaluateYear;
- //Note that with the BSD -T switch, a time can be returned with seconds
- property FoundYear : Word read FFoundYear write FFoundYear;
- property FoundMonth : Word read FFoundMonth write FFoundMonth;
- property FoundDay : Word read FFoundDay write FFoundDay;
- property FoundHour : Word read FFoundHour write FFoundHour;
- property FoundMin : Word read FFoundMin write FFoundMin;
- property FoundSec : Word read FFoundSec write FFoundSec;
- property ExpectedYear : Word read FExpectedYear write FExpectedYear;
- property ExpectedMonth : Word read FExpectedMonth write FExpectedMonth;
- property ExpectedDay : Word read FExpectedDay write FExpectedDay;
- property ExpectedHour : Word read FExpectedHour write FExpectedHour;
- property ExpectedMin : Word read FExpectedMin write FExpectedMin;
- property ExpectedSec : Word read FExpectedSec write FExpectedSec;
- property FoundOwner : String read FFoundOwner write FFoundOwner;
- property ExpectedOwner : String read FExpectedOwner write FExpectedOwner;
- property FoundGroup : String read FFoundGroup write FFoundGroup;
- property ExpectedGroup : String read FExpectedGroup write FExpectedGroup;
- property FoundFileName : String read FFoundFileName write FFoundFileName;
- property ExpectedFileName : String read FExpectedFileName write FExpectedFileName;
- property FoundFileSize : Integer read FFoundFileSize write FFoundFileSize;
- property ExpectedFileSize : Integer read FExpectedFileSize write FExpectedFileSize;
- end;
- TdmFTPListTest = class(TDataModule)
- bxUnixLSandSimilar: TBXBubble;
- bxWin32IISForms: TBXBubble;
- bxSterlingComTests: TBXBubble;
- bxOS2Test: TBXBubble;
- procedure bxUnixLSandSimilarTest(Sender: TBXBubble);
- procedure bxWin32IISFormsTest(Sender: TBXBubble);
- procedure bxSterlingComTestsTest(Sender: TBXBubble);
- procedure bxOS2TestTest(Sender: TBXBubble);
- private
- { Private declarations }
- protected
- procedure ReportItem(AItem : TFTPTestItem);
- //this is for MS-DOS (Win32 style Dir lists where there's no
- //owner or group and where the time and date are supplied
- procedure TestItem(
- ATestItem,
- AExpectedParser,
- AExpectedFileName : String;
- AExpectedFileSize : Integer;
- AExpectedYear,
- AExpectedMonth,
- AExpectedDay,
- AExpectedHour,
- AExpectedMin,
- AExpectedSec : Word); overload;
- //for FreeBSD -T /bin/ls variation and Novell Netware Print Services for Unix (NFS Namespace)
- procedure TestItem(
- ATestItem,
- AExpectedParser,
- AExpectedOwner,
- AExpectedGroup,
- AExpectedFileName : String;
- AExpectedFileSize : Integer;
- AExpectedYear,
- AExpectedMonth,
- AExpectedDay,
- AExpectedHour,
- AExpectedMin,
- AExpectedSec : Word); overload;
- //for /bin/ls with a date within 6 monthes
- procedure TestItem(
- ATestItem,
- AExpectedParser,
- AExpectedOwner,
- AExpectedGroup,
- AExpectedFileName : String;
- AExpectedFileSize : Integer;
- AExpectedMonth,
- AExpectedDay,
- AExpectedHour,
- AExpectedMin,
- AExpectedSec : Word); overload;
- //for /bin/ls with a date greater than 6 monthes
- procedure TestItem(
- ATestItem,
- AExpectedParser,
- AExpectedOwner,
- AExpectedGroup,
- AExpectedFileName : String;
- AExpectedFileSize : Integer;
- AExpectedYear,
- AExpectedMonth,
- AExpectedDay : Word); overload;
- public
- { Public declarations }
- end;
- var
- dmFTPListTest: TdmFTPListTest;
- implementation
- uses IdCoreGlobal, IdAllFTPListParsers, IdFTPList, IdFTPListParseNovellNetwarePSU,
- IdFTPListParseUnix,
- IdFTPListParseBase, IdFTPListParseWindowsNT, IdFTPListParseStercomUnixEnt,
- IdFTPListParseStercomOS390Exp, IdFTPListParseOS2;
-
- {$R *.dfm}
- procedure TdmFTPListTest.bxUnixLSandSimilarTest(Sender: TBXBubble);
- begin
- //drwxrwxrwx 1 user group 0 Mar 3 04:49:59 2003 upload
- //FreeBSD /bin/ls -T format
- TestItem('drwxrwxrwx 1 user group 0 Mar 3 04:49:59 2003 upload',
- UNIX,
- 'user',
- 'group',
- 'upload',
- 0,
- 2003,
- 3,
- 3,
- 4,
- 49,
- 59
- );
- //-rw------- 1 root wheel 512 Oct 14, 99 8:45 pm deleted.sav
- //Novell Netware Print Services for Unix FTP Deamon
- TestItem('-rw------- 1 root wheel 512 Oct 14, 99 8:45 pm deleted.sav',
- NOVELLNETWAREPSU + 'NFS Namespace',
- 'root',
- 'wheel',
- 'deleted.sav',
- 512,
- 1999,
- 10,
- 14,
- 20,
- 45,
- 0);
- //Normal Unix item with time
- TestItem('drwxrwxrwx 1 owner group 0 Sep 23 21:58 drdos',
- UNIX,
- 'owner',
- 'group',
- 'drdos',
- 0,
- 9,
- 23,
- 21,
- 58,
- 0);
- //drwxr-xr-x 4 ftpuser ftpusers 512 Jul 23 2001 about
- //Normal Unix item with year
- TestItem('drwxr-xr-x 4 ftpuser ftpusers 512 Jul 23 2001 about',
- UNIX,
- 'ftpuser',
- 'ftpusers',
- 'about',
- 512,
- 2001,
- 7,
- 23);
- // -rw------- 1 strauss staff DK adams 39 Feb 18 11:23 file2
- // Unitree with Time
- TestItem('-rw------- 1 strauss staff DK adams 39 Feb 18 11:23 file2',
- UNITREE,
- 'strauss',
- 'staff',
- 'file2',
- 39,
- 2,
- 18,
- 11,
- 23,
- 0);
- //Unitree with Date
- TestItem('drwxr-xr-x 2 se2nl g664 DK common 8192 Dec 29 1993 encytemp (Empty)',
- UNITREE,
- 'se2nl',
- 'g664',
- 'encytemp (Empty)',
- 8192,
- 1993,
- 12,
- 29);
- TestItem('drwxr-xr-x 2 root 110 4096 Sep 27 2000 oracle',
- UNIX,
- 'root',
- '110',
- 'oracle',
- 4096,
- 2000,
- 9,
- 27);
- TestItem('-r--r--r-- 1 0 1 351 Aug 8 2000 Welcome',
- UNIX,
- '0',
- '1',
- 'Welcome',
- 351,
- 2000,
- 8,
- 8);
- //-go switches
- TestItem('-r--r--r-- 1 351 Aug 8 2000 Welcome',
- UNIX,
- '',
- '',
- 'Welcome',
- 351,
- 2000,
- 8,
- 8 );
- //-g switch
- TestItem('-r--r--r-- 1 1 351 Aug 8 2000 Welcome',
- UNIX,
- '',
- '1',
- 'Welcome',
- 351,
- 2000,
- 8,
- 8);
- TestItem('-r--r--r-- 1 0 351 Aug 8 2000 Welcome',
- UNIX,
- '',
- '0', //really the owner but for coding, it's the group because
- //you can't desinguish a group and owner with one value and on
- //a server, you can't make an API call.
- 'Welcome',
- 351,
- 2000,
- 8,
- 8);
- //-i switch
- TestItem(' 33025 -r--r--r-- 1 root other 351 Aug 8 2000 Welcome',
- UNIX,
- 'root',
- 'other',
- 'Welcome',
- 351,
- 2000,
- 8,
- 8);
- //-s switch
- TestItem(' 16 -r--r--r-- 1 root other 351 Aug 8 2000 Welcome',
- UNIX,
- 'root',
- 'other',
- 'Welcome',
- 351,
- 2000,
- 8,
- 8);
- //-is switches
- TestItem(' 33025 16 -r--r--r-- 1 root other 351 Aug 8 2000 Welcome',
- UNIX,
- 'root',
- 'other',
- 'Welcome',
- 351,
- 2000,
- 8,
- 8);
- TestItem('1008201 33 -rw-r--r-- 1 204 wheel 32871 Mar 4 16:45:27 1999 nl-ftp',
- UNIX,
- '204',
- 'wheel',
- 'nl-ftp',
- 32871,
- 1999,
- 3,
- 4,
- 16,
- 45,
- 27);
- //char devices
- TestItem('crw-rw-rw- 1 0 1 11, 42 Aug 8 2000 tcp',
- UNIX,
- '0',
- '1',
- 'tcp',
- 0,
- 2000,
- 8,
- 8);
- TestItem('crw-rw-rw- 1 0 1 105, 1 Aug 8 2000 ticotsord',
- UNIX,
- '0',
- '1',
- 'ticotsord',
- 0,
- 2000,
- 8,
- 8);
- // a /bin/ls form with a ACL.
- TestItem('drwx------+ 7 Administ mkpasswd 86016 Feb 9 18:04 bin',
- UNIX,
- 'Administ',
- 'mkpasswd',
- 'bin',
- 86016,
- 2,
- 9,
- 18,
- 4,
- 0);
- //Note that this is problematic and I doubt we can ever fix for this one without
- //introducing other problems.
- { TestItem('-rw-r--r-- 1 J. Peter Mugaas None 862979 Apr 8 2002 kftp.exe',
- UNIX,
- 'J. Peter Mugaas',
- 'None',
- 'kftp.exe',
- 862979,
- 2002,
- 4,
- 8); }
- //taken from remarks in the FileZilla GNU Source-code - note that non of that
- //code is used at all
- // /* Some listings with uncommon date/time format: */
- // "-rw-r--r-- 1 root other 531 09-26 2000 README2",
- TestItem('-rw-r--r-- 1 root other 531 09-26 2000 README2',
- UNIX,
- 'root',
- 'other',
- 'README2',
- 531,
- 2000,
- 9,
- 26);
- // "-rw-r--r-- 1 root other 531 09-26 13:45 README3",
- TestItem('-rw-r--r-- 1 root other 531 09-26 13:45 README3',
- UNIX,
- 'root',
- 'other',
- 'README3',
- 531,
- 9,
- 26,
- 13,
- 45,
- 0);
- // "-rw-r--r-- 1 root other 531 2005-06-07 21:22 README4
- TestItem('-rw-r--r-- 1 root other 531 2005-06-07 21:22 README4',
- UNIX,
- 'root',
- 'other',
- 'README4',
- 2005,
- 6,
- 7,
- 21,
- 22,
- 0);
- TestItem('---------- 1 owner group 1803128 Jul 10 10:18 ls-lR.Z',
- UNIX,
- 'owner',
- 'group',
- 'ls-lR.Z',
- 1803128,
- 7,
- 10,
- 10,
- 18,
- 0);
- TestItem('d--------- 1 owner group 0 May 9 19:45 Softlib',
- UNIX,
- 'owner',
- 'group',
- 'Softlib',
- 0,
- 5,
- 9,
- 19,
- 45,
- 0);
- // CONNECT:Enterprise for UNIX login ok,
- TestItem('-r--r--r-- 1 connect 3444 910368 Sep 24 16:36 c3957010.zip.001',
- UNIX,
- 'connect',
- '3444',
- 'c3957010.zip.001',
- 910368,
- 9,
- 24,
- 16,
- 36,
- 0);
- TestItem('-r--r--r-- 1 connect 2755 6669222 Sep 26 08:11 3963338.fix.000',
- UNIX,
- 'connect',
- '2755',
- '3963338.fix.000',
- 6669222,
- 9,
- 26,
- 8,
- 11,
- 0);
- TestItem('-r--r--r-- 1 connect 3188 6669222 Sep 26 13:12 c3963338.zip',
- UNIX,
- 'connect',
- '3188',
- 'c3963338.zip',
- 6669222,
- 9,
- 26,
- 13,
- 12,
- 0);
- end;
- procedure TdmFTPListTest.ReportItem(AItem: TFTPTestItem);
- var LStatus : String;
- begin
- bxUnixLSandSimilar.Status('Item: ');
- bxUnixLSandSimilar.Status(AItem.TestItem);
- //filename
- LStatus :=
- 'Obtained File name: '+ AItem.FoundFileName + EOL +'Expected name: '+AItem.ExpectedFileName ;
- bxUnixLSandSimilar.Status(LStatus);
- bxUnixLSandSimilar.Check(AItem.FoundFileName=AItem.ExpectedFileName, LSTatus);
- //parserID
- LStatus := 'Obtained Parser ID: '+ AItem.FoundParser +EOL+
- 'Expected Parser ID: '+ AItem.ExpectedParser;
- bxUnixLSandSimilar.Status(LStatus);
- bxUnixLSandSimilar.Check(AItem.FoundFileName=AItem.ExpectedFileName,LStatus);
- //Owner
- LStatus := 'Obtained Owner: '+ AItem.FoundOwner +EOL+'Expected Owner: '+ AItem.ExpectedOwner;
- bxUnixLSandSimilar.Status(LStatus);
- bxUnixLSandSimilar.Check(AItem.FoundOwner =AItem.ExpectedOwner, LStatus );
- //Group
- LStatus :='Obtained Group: '+ AItem.FoundGroup +EOL+'Expected Group: '+ AItem.ExpectedGroup;
- bxUnixLSandSimilar.Status(LStatus);
- bxUnixLSandSimilar.Check(AItem.FoundGroup =AItem.ExpectedGroup,LStatus );
- //Date
- // Year - note that this may skipped in some cases as explained above
- if AItem.FEvaluateYear then
- begin
- LStatus := 'Obtained Year: '+ IntToStr(AItem.FFoundYear ) +EOL+'Expected Year: '+ IntToStr(AItem.ExpectedYear );
- bxUnixLSandSimilar.Status(LStatus);
- bxUnixLSandSimilar.Check(AItem.FoundYear =AItem.ExpectedYear,LStatus );
- end;
- //month
- LStatus := 'Obtained Month: '+ IntToStr(AItem.FoundMonth) +EOL+'Expected Month: '+ IntToStr(AItem.ExpectedMonth);
- bxUnixLSandSimilar.Status(LStatus);
- bxUnixLSandSimilar.Check(AItem.FoundMonth =AItem.ExpectedMonth,LStatus );
- //day
- LStatus :='Obtained Day: '+ IntToStr(AItem.FoundDay) +EOL+'Expected Day: '+ IntToStr(AItem.ExpectedDay);
- bxUnixLSandSimilar.Status(LStatus);
- bxUnixLSandSimilar.Check(AItem.FoundDay =AItem.ExpectedDay,LStatus );
- //time
- if AItem.EvaluateTime then
- begin
- //Hour
- LStatus := 'Obtained Hour: '+ IntToStr(AItem.FoundHour) +EOL+'Expected Hour: '+ IntToStr(AItem.ExpectedHour);
- bxUnixLSandSimilar.Status(LStatus);
- bxUnixLSandSimilar.Check(AItem.FoundHour =AItem.ExpectedHour, LStatus );
- //Minute
- LStatus := 'Obtained Minute: '+ IntToStr(AItem.FoundMin) +EOL+'Expected Minute: '+ IntToStr(AItem.ExpectedMin);
- bxUnixLSandSimilar.Status(LStatus);
- bxUnixLSandSimilar.Check(AItem.FoundMin =AItem.ExpectedMin, LStatus);
- //Sec
- LStatus := 'Obtained Second: '+ IntToStr(AItem.FoundSec) +EOL+'Expected Second: '+ IntToStr(AItem.ExpectedSec);
- bxUnixLSandSimilar.Status(LStatus);
- bxUnixLSandSimilar.Check(AItem.FoundSec =AItem.ExpectedSec, LStatus );
- end;
- //Size
- LStatus := 'Obtained Size: '+ IntToStr(AItem.FoundFileSize ) +EOL+'Expected Size: '+ IntToStr(AItem.ExpectedFileSize ) ;
- bxUnixLSandSimilar.Status(LStatus);
- bxUnixLSandSimilar.Check(AItem.FoundSec =AItem.ExpectedSec, LStatus );
- end;
- { TFTPTestItem }
- procedure TFTPTestItem.Clear;
- begin
- FTestItem := '';
- FFoundParser := '';
- FExpectedParser := '';
- //note that the Unix servers can normally only report either a year
- //or a time. This can cause ambiguity because the year is interpretted
- //according to the current or previous year if the date has passed or arrived. But
- //because we can't know the local time zone, there can be a 24 hour window
- //of time. E.g. Sept 8 10:00am 2003 can be interpretted as either Sept 8 10:00am 2003 or
- //Sept 8, 2002 if in the window of Sept 7 10:00am or Sept 9 10:00am.
- //Otherwise, a date such as Sept 8: 10:00am can be interpretted differently at different
- //times of the year (when the window period has passed - 2002 or before the window 2003.
- FEvaluateTime := True;
- FEvaluateYear := True;
- //Note that with the BSD -T switch, a time can be returned with seconds
- FFoundYear := 0;
- FExpectedYear := 0;
- FFoundMonth := 0;
- FFoundDay := 0;
- FFoundHour := 0;
- FFoundMin := 0;
- FFoundSec := 0;
- FExpectedMonth := 0;
- FExpectedDay := 0;
- FExpectedHour := 0;
- FExpectedMin := 0;
- FExpectedSec := 0;
- FFoundOwner := '';
- FExpectedOwner := '';
- FFoundGroup := '';
- FExpectedGroup := '';
- FFoundFileName := '';
- FExpectedFileName := '';
- FFoundFileSize := 0;
- FExpectedFileSize := 0;
- end;
- procedure TdmFTPListTest.TestItem(ATestItem, AExpectedParser,
- AExpectedFileName: String; AExpectedFileSize: Integer; AExpectedYear,
- AExpectedMonth, AExpectedDay, AExpectedHour, AExpectedMin,
- AExpectedSec: Word);
- begin
- TestItem(ATestItem,AExpectedParser,'','',AExpectedFileName,AExpectedFileSize,AExpectedYear,AExpectedMonth,AExpectedDay,AExpectedHour,AExpectedMin,AExpectedSec);
- end;
- procedure TdmFTPListTest.TestItem(ATestItem, AExpectedParser,
- AExpectedOwner, AExpectedGroup, AExpectedFileName: String;
- AExpectedFileSize: Integer; AExpectedYear, AExpectedMonth, AExpectedDay,
- AExpectedHour, AExpectedMin, AExpectedSec: Word);
- var LT : TFTPTestItem;
- LDir : TStrings;
- LDirItems : TIdFTPListItems;
- LFormat : String;
- LFTPDir : TFTPTestItem;
- LI : TIdFTPListItem;
- LDummy : Word;
- begin
- LT := TFTPTestItem.Create;
- try
- LDir := TStringList.Create;
- LDirItems := TIdFTPListItems.Create;
- LDir.Add(ATestItem);
- LFTPDir := TFTPTestItem.Create;
- LFTPDir.TestItem := ATestItem;
- CheckListParse(LDir,LDirItems,LFormat);
- LFTPDir.EvaluateYear := True;
- LFTPDir.EvaluateTime := True;
- LFTPDir.FoundParser := LFormat;
- LFTPDir.ExpectedParser := AExpectedParser;
- if LDirItems.Count <> 1 then
- begin
- raise Exception.Create('Only 1 item from the parser is expected');
- end
- else
- begin
- LI := LDirItems[0];
- end;
- DecodeDate( LI.ModifiedDate,LFTPDir.FFoundYear,LFTPDir.FFoundMonth,LFTPDir.FFoundDay);
- DecodeTime( LI.ModifiedDate,LFTPDir.FFoundHour,LFTPDir.FFoundMin,LFTPDir.FFoundSec,LDummy);
- LFTPDir.FoundOwner := LI.OwnerName;
- LFTPDir.FoundGroup := LI.GroupName;
- LFTPDir.FoundFileName := LI.FileName;
- LFTPDir.FoundFileSize := LI.Size;
- LFTPDir.ExpectedYear := AExpectedYear;
- LFTPDir.ExpectedMonth := AExpectedMonth;
- LFTPDir.ExpectedDay := AExpectedDay;
- LFTPDir.ExpectedHour := AExpectedHour;
- LFTPDir.ExpectedMin := AExpectedMin;
- LFTPDir.ExpectedSec := AExpectedSec;
- LFTPDir.ExpectedOwner := AExpectedOwner;
- LFTPDir.ExpectedGroup := AExpectedGroup;
- LFTPDir.ExpectedFileName := AExpectedFileName;
- LFTPDir.ExpectedFileSize := AExpectedFileSize;
- ReportItem(LFTPDir);
- finally
- FreeAndNil(LFTPDir);
- FreeAndNil(LDirItems);
- FreeAndNil(LDir);
- FreeAndNil(LT);
- end;
- end;
- procedure TdmFTPListTest.TestItem(ATestItem, AExpectedParser,
- AExpectedOwner, AExpectedGroup, AExpectedFileName: String;
- AExpectedFileSize: Integer; AExpectedMonth, AExpectedDay, AExpectedHour,
- AExpectedMin, AExpectedSec: Word);
- var LT : TFTPTestItem;
- LDir : TStrings;
- LDirItems : TIdFTPListItems;
- LFormat : String;
- LFTPDir : TFTPTestItem;
- LI : TIdFTPListItem;
- LDummy : Word;
- begin
- LT := TFTPTestItem.Create;
- try
- LDir := TStringList.Create;
- LDirItems := TIdFTPListItems.Create;
- LDir.Add(ATestItem);
- LFTPDir := TFTPTestItem.Create;
- LFTPDir.TestItem := ATestItem;
- CheckListParse(LDir,LDirItems,LFormat);
- LFTPDir.EvaluateYear := False;
- LFTPDir.EvaluateTime := True;
- LFTPDir.FoundParser := LFormat;
- LFTPDir.ExpectedParser := AExpectedParser;
- if LDirItems.Count <> 1 then
- begin
- raise Exception.Create('Only 1 item from the parser is expected');
- end
- else
- begin
- LI := LDirItems[0];
- end;
- DecodeDate( LI.ModifiedDate,LFTPDir.FFoundYear,LFTPDir.FFoundMonth,LFTPDir.FFoundDay);
- DecodeTime( LI.ModifiedDate,LFTPDir.FFoundHour,LFTPDir.FFoundMin,LFTPDir.FFoundSec,LDummy);
- LFTPDir.FoundOwner := LI.OwnerName;
- LFTPDir.FoundGroup := LI.GroupName;
- LFTPDir.FoundFileName := LI.FileName;
- LFTPDir.FoundFileSize := LI.Size;
- LFTPDir.ExpectedMonth := AExpectedMonth;
- LFTPDir.ExpectedDay := AExpectedDay;
- LFTPDir.ExpectedHour := AExpectedHour;
- LFTPDir.ExpectedMin := AExpectedMin;
- LFTPDir.ExpectedSec := AExpectedSec;
- LFTPDir.ExpectedOwner := AExpectedOwner;
- LFTPDir.ExpectedGroup := AExpectedGroup;
- LFTPDir.ExpectedFileName := AExpectedFileName;
- LFTPDir.ExpectedFileSize := AExpectedFileSize;
- ReportItem(LFTPDir);
- finally
- FreeAndNil(LFTPDir);
- FreeAndNil(LDirItems);
- FreeAndNil(LDir);
- FreeAndNil(LT);
- end;
- end;
- procedure TdmFTPListTest.TestItem(ATestItem, AExpectedParser,
- AExpectedOwner, AExpectedGroup, AExpectedFileName: String;
- AExpectedFileSize: Integer; AExpectedYear, AExpectedMonth, AExpectedDay : Word);
- var LT : TFTPTestItem;
- LDir : TStrings;
- LDirItems : TIdFTPListItems;
- LFormat : String;
- LFTPDir : TFTPTestItem;
- LI : TIdFTPListItem;
- LDummy : Word;
- begin
- LT := TFTPTestItem.Create;
- try
- LDir := TStringList.Create;
- LDirItems := TIdFTPListItems.Create;
- LDir.Add(ATestItem);
- LFTPDir := TFTPTestItem.Create;
- LFTPDir.TestItem := ATestItem;
- CheckListParse(LDir,LDirItems,LFormat);
- LFTPDir.EvaluateYear := True;
- LFTPDir.EvaluateTime := False;
- LFTPDir.FoundParser := LFormat;
- LFTPDir.ExpectedParser := AExpectedParser;
- if LDirItems.Count <> 1 then
- begin
- raise Exception.Create('Only 1 item from the parser is expected');
- end
- else
- begin
- LI := LDirItems[0];
- end;
- DecodeDate( LI.ModifiedDate,LFTPDir.FFoundYear,LFTPDir.FFoundMonth,LFTPDir.FFoundDay);
- DecodeTime( LI.ModifiedDate,LFTPDir.FFoundHour,LFTPDir.FFoundMin,LFTPDir.FFoundSec,LDummy);
- LFTPDir.FoundOwner := LI.OwnerName;
- LFTPDir.FoundGroup := LI.GroupName;
- LFTPDir.FoundFileName := LI.FileName;
- LFTPDir.FoundFileSize := LI.Size;
- LFTPDir.ExpectedYear := AExpectedYear;
- LFTPDir.ExpectedMonth := AExpectedMonth;
- LFTPDir.ExpectedDay := AExpectedDay;
- LFTPDir.ExpectedOwner := AExpectedOwner;
- LFTPDir.ExpectedGroup := AExpectedGroup;
- LFTPDir.ExpectedFileName := AExpectedFileName;
- LFTPDir.ExpectedFileSize := AExpectedFileSize;
- ReportItem(LFTPDir);
- finally
- FreeAndNil(LFTPDir);
- FreeAndNil(LDirItems);
- FreeAndNil(LDir);
- FreeAndNil(LT);
- end;
- end;
- procedure TdmFTPListTest.bxWin32IISFormsTest(Sender: TBXBubble);
- begin
- {Note that these were taken from comments in the FileZilla source-code.
- Note that no GNU source-code from that program was used in source-code.
- }
- //04-27-00 09:09PM <DIR> DOS dir 1
- TestItem(
- '04-27-00 09:09PM <DIR> DOS dir 1',
- WINNTID,
- 'DOS dir 1',
- 0,
- 2000,
- 4,
- 27,
- 21,
- 9,
- 0);
- //04-14-00 03:47PM 589 DOS file 1
- // procedure TestItem(
- // ATestItem,
- // AExpectedParser,
- // AExpectedFileName : String;
- // AExpectedFileSize : Integer;
- // AExpectedYear,
- // AExpectedMonth,
- // AExpectedDay,
- // AExpectedHour,
- // AExpectedMin,
- // AExpectedSec : Word); overload;
- //Microsoft IIS using Unix format
- TestItem(
- '04-14-00 03:47PM 589 DOS file 1',
- WINNTID,
- 'DOS file 1',
- 589,
- 2000,
- 4,
- 14,
- 15,
- 47,
- 0);
- //2002-09-02 18:48 <DIR> DOS dir 2
- TestItem(
- '2002-09-02 18:48 <DIR> DOS dir 2',
- WINNTID,
- 'DOS dir 2',
- 0,
- 2002,
- 9,
- 2,
- 18,
- 48,
- 0);
- //2002-09-02 19:06 9,730 DOS file 2
- TestItem(
- '2002-09-02 19:06 9,730 DOS file 2',
- WINNTID,
- 'DOS file 2',
- 9730,
- 2002,
- 9,
- 2,
- 19,
- 6,
- 0);
- end;
- procedure TdmFTPListTest.bxSterlingComTestsTest(Sender: TBXBubble);
- begin
- TestItem(
- '-C--E-----FTP B QUA1I1 18128 41 Aug 12 13:56 QUADTEST',
- STIRCOMUNIX,
- 'QUA1I1',
- '',
- 'QUADTEST',
- 41,
- 8,
- 12,
- 13,
- 56,
- 0);
- TestItem(
- '-C--E-----FTP A QUA1I1 18128 41 Aug 12 13:56 QUADTEST2',
- STIRCOMUNIX,
- 'QUA1I1',
- '',
- 'QUADTEST2',
- 41,
- 8,
- 12,
- 13,
- 56,
- 0);
- TestItem(
- '-ARTE-----TCP A cbeodm 22159 629629 Aug 06 05:47 PSEUDOFILENAME',
- STIRCOMUNIX,
- 'cbeodm',
- '',
- 'PSEUDOFILENAME',
- 629629,
- 8,
- 6,
- 5,
- 47,
- 0);
- TestItem(
- 'solution 00003444 00910368 <c3957010.zip.001> 030924-1636 A R TCP BIN',
- STIRCOMUNIXNS,
- 'solution',
- '',
- 'c3957010.zip.001',
- 00910368,
- 2003,
- 9,
- 24,
- 16,
- 36,
- 0);
- TestItem('solution 00003048 00007341 <POST1202.P1182069.R>+ 030926-0832 A RT TCP ASC',
- STIRCOMUNIXNS,
- 'solution',
- '',
- 'POST1202.P1182069.R', //filename was truncated by the dir format
- 00007341,
- 2003,
- 9,
- 26,
- 8,
- 32,
- 0);
- {
- From:
- "Connect:Enterprise® UNIX Remote User’s Guide Version 2.1 " Copyright
- 1999, 2002, 2003 Sterling Commerce, Inc.
- ==
- -C--E-----FTP A steve 2 41 Sep 02 13:47 test.c
- -SR--M------- A steve 1 369 Sep 02 13:47 <<ACTIVITY LOG>>
- Total number of batches listed: 2
- ==
- }
- TestItem('-C--E-----FTP A steve 2 41 Sep 02 13:47 test.c',
- STIRCOMUNIX,
- 'steve',
- '',
- 'test.c',
- 41,
- 9,
- 2,
- 13,
- 47,
- 0);
- TestItem('-SR--M------- A steve 1 369 Sep 02 13:47 <<ACTIVITY LOG>>',
- STIRCOMUNIX,
- 'steve',
- '',
- '<<ACTIVITY LOG>>',
- 369,
- 9,
- 2,
- 13,
- 47,
- 0);
- {The proper parser is incapable of returning a date}
- TestItem('d - - - - - - - steve',
- STIRCOMUNIXROOT,
- '',
- '',
- 'steve',
- 0,
- 12,
- 30,
- 0,
- 0,
- 0);
- {Sterling Commerce Express for OS/390 tests}
- TestItem('-D 2 T VB 00244 18000 FTPGDG!PSR$TST.GDG.TSTGDG0(+01)',
- STIRCOMEXPOS390,
- '',
- '',
- 'FTPGDG!PSR$TST.GDG.TSTGDG0(+01)',
- 0,
- 12,
- 30,
- 0,
- 0,
- 0);
- TestItem('-D 2 * VB 00244 27800 FTPV!PSR$TST.A.VVV.&REQNUMB',
- STIRCOMEXPOS390,
- '',
- '',
- 'FTPV!PSR$TST.A.VVV.&REQNUMB',
- 0,
- 12,
- 30,
- 0,
- 0,
- 0);
- TestItem('-F 1 R - - - FTPVAL1!PSR$TST.A.VVV',
- STIRCOMEXPOS390,
- '',
- '',
- 'FTPVAL1!PSR$TST.A.VVV',
- 0,
- 12,
- 30,
- 0,
- 0,
- 0);
- end;
- procedure TdmFTPListTest.bxOS2TestTest(Sender: TBXBubble);
- { From: Jakarta Apache project's test suite.
- " 0 DIR 12-30-97 12:32 jbrekke",
- " 0 DIR 11-25-97 09:42 junk",
- " 0 DIR 05-12-97 16:44 LANGUAGE",
- " 0 DIR 05-19-97 12:56 local",
- " 0 DIR 05-12-97 16:52 Maintenance Desktop",
- " 0 DIR 05-13-97 10:49 MPTN",
- "587823 RSA DIR 01-08-97 13:58 OS2KRNL",
- " 33280 A 02-09-97 13:49 OS2LDR",
- " 0 DIR 11-28-97 09:42 PC",
- "149473 A 11-17-98 16:07 POPUPLOG.OS2",
- " 0 DIR 05-12-97 16:44 PSFONTS"
- }
- begin
- {note that some of servers are probably NOT Y2K complient}
- TestItem(
- ' 0 DIR 12-30-97 12:32 jbrekke',
- OS2PARSER,
- 'jbrekke',
- 0,
- 1997,
- 12,
- 30,
- 12,
- 32,
- 0);
- TestItem(
- ' 73098 A 04-06-97 15:15 ds0.internic.net1996052434624.txt',
- OS2PARSER,
- 'ds0.internic.net1996052434624.txt',
- 73098,
- 1997,
- 4,
- 6,
- 15,
- 15,
- 0);
- {
- taken from the FileZilla source-code comments
- " 0 DIR 05-12-97 16:44 PSFONTS"
- "36611 A 04-23-103 10:57 OS2 test1.file"
- " 1123 A 07-14-99 12:37 OS2 test2.file"
- " 0 DIR 02-11-103 16:15 OS2 test1.dir"
- " 1123 DIR A 10-05-100 23:38 OS2 test2.dir"
- }
- TestItem(
- ' 0 DIR 05-12-97 16:44 PSFONTS',
- OS2PARSER,
- 'PSFONTS',
- 0,
- 1997,
- 5,
- 12,
- 16,
- 44,
- 0);
- TestItem(
- '36611 A 04-23-103 10:57 OS2 test1.file',
- OS2PARSER,
- 'OS2 test1.file',
- 36611,
- 2003,
- 4,
- 23,
- 10,
- 57,
- 0);
- TestItem(
- ' 1123 A 07-14-99 12:37 OS2 test2.file',
- OS2PARSER,
- 'OS2 test2.file',
- 1123,
- 1999,
- 7,
- 14,
- 12,
- 37,
- 0);
- TestItem(
- ' 0 DIR 02-11-103 16:15 OS2 test1.dir',
- OS2PARSER,
- 'OS2 test1.dir',
- 0,
- 2003,
- 2,
- 11,
- 16,
- 15,
- 0);
- TestItem(
- ' 1123 DIR A 10-05-100 23:38 OS2 test2.dir',
- OS2PARSER,
- 'OS2 test2.dir',
- 1123,
- 2000,
- 10,
- 5,
- 23,
- 38,
- 0);
- end;
- end.
|