ObjFW  Check-in [2aad218748]

Overview
Comment:Migrate OFHTTPCookieManagerTests to ObjFWTest
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | objfwtest
Files: files | file ages | folders
SHA3-256: 2aad218748bdfb0dcf1750c91f2acf304ee2d0e0bd82e2bda574501332f353c2
User & Date: js on 2024-02-17 22:23:24
Other Links: branch diff | manifest | tags
Context
2024-02-18
10:11
Migrate OFHTTPClientTests to ObjFWTest check-in: 851f6138bf user: js tags: objfwtest
2024-02-17
22:23
Migrate OFHTTPCookieManagerTests to ObjFWTest check-in: 2aad218748 user: js tags: objfwtest
22:12
Migrate OFHTTPCookieTests to ObjFWTest check-in: 677b61582e user: js tags: objfwtest
Changes

Modified new_tests/Makefile from [9151d329b2] to [87e80c1e61].

52
53
54
55
56
57
58
59
60
61
62
63
64
65








66
67
68
69
70
71
72
52
53
54
55
56
57
58







59
60
61
62
63
64
65
66
67
68
69
70
71
72
73







-
-
-
-
-
-
-
+
+
+
+
+
+
+
+







       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_SUBPROCESSES}		\
       ${USE_SRCS_THREADS}		\
       ${USE_SRCS_WINDOWS}		\
       testfile_bin.m			\
       testfile_ini.m
SRCS_PLUGINS = OFPluginTests.m
SRCS_SOCKETS = OFHTTPCookieTests.m	\
	       OFDNSResolverTests.m	\
	       OFSocketTests.m		\
	       OFTCPSocketTests.m	\
	       OFUDPSocketTests.m	\
	       ${USE_SRCS_IPX}		\
	       ${USE_SRCS_UNIX_SOCKETS}	\
SRCS_SOCKETS = OFHTTPCookieManagerTests.m	\
	       OFHTTPCookieTests.m		\
	       OFDNSResolverTests.m		\
	       OFSocketTests.m			\
	       OFTCPSocketTests.m		\
	       OFUDPSocketTests.m		\
	       ${USE_SRCS_IPX}			\
	       ${USE_SRCS_UNIX_SOCKETS}		\
	       ${USE_SRCS_APPLETALK}
SRCS_APPLETALK = OFDDPSocketTests.m
SRCS_IPX = OFIPXSocketTests.m		\
	   OFSPXSocketTests.m		\
	   OFSPXStreamSocketTests.m
SRCS_UNIX_SOCKETS = OFUNIXDatagramSocketTests.m	\
		    OFUNIXStreamSocketTests.m

Renamed and modified tests/OFHTTPCookieManagerTests.m [fdaaae41cf] to new_tests/OFHTTPCookieManagerTests.m [03be30a247].

11
12
13
14
15
16
17
18


19
20


21
22
23


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

40
41
42
43


44
45
46
47
48
49

50
51
52
53
54



55
56
57
58
59
60
61

62
63
64
65
66



67
68
69
70
71
72
73
74

75
76
77
78
79
80




81
82
83
84
85
86

87
88
89
90
91
92




93
94
95
96
97
98
99
100






101
102
103
11
12
13
14
15
16
17

18
19
20

21
22
23


24
25
26

27
28
29
30
31
32
33
34
35
36
37
38


39




40
41
42
43
44
45


46





47
48
49
50
51
52
53
54


55





56
57
58
59
60
61
62
63
64


65






66
67
68
69
70
71
72
73


74






75
76
77
78
79







80
81
82
83
84
85


86







-
+
+

-
+
+

-
-
+
+

-












-
-
+
-
-
-
-
+
+




-
-
+
-
-
-
-
-
+
+
+





-
-
+
-
-
-
-
-
+
+
+






-
-
+
-
-
-
-
-
-
+
+
+
+




-
-
+
-
-
-
-
-
-
+
+
+
+

-
-
-
-
-
-
-
+
+
+
+
+
+
-
-

 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "TestsAppDelegate.h"
#import "ObjFW.h"
#import "ObjFWTest.h"

static OFString *const module = @"OFHTTPCookieManager";
@interface OFHTTPCookieManagerTests: OTTestCase
@end

@implementation TestsAppDelegate (OFHTTPCookieManagerTests)
- (void)HTTPCookieManagerTests
@implementation OFHTTPCookieManagerTests
- (void)testCookieManager
{
	void *pool = objc_autoreleasePoolPush();
	OFHTTPCookieManager *manager = [OFHTTPCookieManager manager];
	OFIRI *IRI1, *IRI2, *IRI3, *IRI4;
	OFHTTPCookie *cookie1, *cookie2, *cookie3, *cookie4, *cookie5;

	IRI1 = [OFIRI IRIWithString: @"http://nil.im/foo"];
	IRI2 = [OFIRI IRIWithString: @"https://nil.im/foo/bar"];
	IRI3 = [OFIRI IRIWithString: @"https://test.nil.im/foo/bar"];
	IRI4 = [OFIRI IRIWithString: @"http://webkeks.org/foo/bar"];

	cookie1 = [OFHTTPCookie cookieWithName: @"test"
					 value: @"1"
					domain: @"nil.im"];
	TEST(@"-[addCookie:forIRI:] #1",
	    R([manager addCookie: cookie1 forIRI: IRI1]))
	[manager addCookie: cookie1 forIRI: IRI1];

	TEST(@"-[cookiesForIRI:] #1",
	    [[manager cookiesForIRI: IRI1] isEqual:
	    [OFArray arrayWithObject: cookie1]])
	OTAssertEqualObjects([manager cookiesForIRI: IRI1],
	    [OFArray arrayWithObject: cookie1]);

	cookie2 = [OFHTTPCookie cookieWithName: @"test"
					 value: @"2"
					domain: @"webkeks.org"];
	TEST(@"-[addCookie:forIRI:] #2",
	    R([manager addCookie: cookie2 forIRI: IRI1]))
	[manager addCookie: cookie2 forIRI: IRI1];

	TEST(@"-[cookiesForIRI:] #2",
	    [[manager cookiesForIRI: IRI1] isEqual:
	    [OFArray arrayWithObject: cookie1]] &&
	    [[manager cookiesForIRI: IRI4] isEqual: [OFArray array]])
	OTAssertEqualObjects([manager cookiesForIRI: IRI1],
	    [OFArray arrayWithObject: cookie1]);
	OTAssertEqualObjects([manager cookiesForIRI: IRI4], [OFArray array]);

	cookie3 = [OFHTTPCookie cookieWithName: @"test"
					 value: @"3"
					domain: @"nil.im"];
	cookie3.secure = true;
	TEST(@"-[addCookie:forIRI:] #3",
	    R([manager addCookie: cookie3 forIRI: IRI2]))
	[manager addCookie: cookie3 forIRI: IRI2];

	TEST(@"-[cookiesForIRI:] #3",
	    [[manager cookiesForIRI: IRI2] isEqual:
	    [OFArray arrayWithObject: cookie3]] &&
	    [[manager cookiesForIRI: IRI1] isEqual: [OFArray array]])
	OTAssertEqualObjects([manager cookiesForIRI: IRI2],
	    [OFArray arrayWithObject: cookie3]);
	OTAssertEqualObjects([manager cookiesForIRI: IRI1], [OFArray array]);

	cookie3.expires = [OFDate dateWithTimeIntervalSinceNow: -1];
	cookie4 = [OFHTTPCookie cookieWithName: @"test"
					 value: @"4"
					domain: @"nil.im"];
	cookie4.domain = @".nil.im";
	TEST(@"-[addCookie:forIRI:] #4",
	    R([manager addCookie: cookie4 forIRI: IRI2]))
	[manager addCookie: cookie4 forIRI: IRI2];

	TEST(@"-[cookiesForIRI:] #4",
	    [[manager cookiesForIRI: IRI2] isEqual:
	    [OFArray arrayWithObject: cookie4]] &&
	    [[manager cookiesForIRI: IRI3] isEqual:
	    [OFArray arrayWithObject: cookie4]])
	OTAssertEqualObjects([manager cookiesForIRI: IRI2],
	    [OFArray arrayWithObject: cookie4]);
	OTAssertEqualObjects([manager cookiesForIRI: IRI3],
	    [OFArray arrayWithObject: cookie4]);

	cookie5 = [OFHTTPCookie cookieWithName: @"bar"
					 value: @"5"
					domain: @"test.nil.im"];
	TEST(@"-[addCookie:forIRI:] #5",
	    R([manager addCookie: cookie5 forIRI: IRI1]))
	[manager addCookie: cookie5 forIRI: IRI1];

	TEST(@"-[cookiesForIRI:] #5",
	    [[manager cookiesForIRI: IRI1] isEqual:
	    [OFArray arrayWithObject: cookie4]] &&
	    [[manager cookiesForIRI: IRI3] isEqual:
	    [OFArray arrayWithObjects: cookie4, cookie5, nil]])
	OTAssertEqualObjects([manager cookiesForIRI: IRI1],
	    [OFArray arrayWithObject: cookie4]);
	OTAssertEqualObjects([manager cookiesForIRI: IRI3],
	    ([OFArray arrayWithObjects: cookie4, cookie5, nil]));

	TEST(@"-[purgeExpiredCookies]",
	    [manager.cookies isEqual:
	    [OFArray arrayWithObjects: cookie3, cookie4, cookie5, nil]] &&
	    R([manager purgeExpiredCookies]) &&
	    [manager.cookies isEqual:
	    [OFArray arrayWithObjects: cookie4, cookie5, nil]])

	OTAssertEqualObjects(manager.cookies,
	    ([OFArray arrayWithObjects: cookie3, cookie4, cookie5, nil]));
	[manager purgeExpiredCookies];
	OTAssertEqualObjects(manager.cookies,
	    ([OFArray arrayWithObjects: cookie4, cookie5, nil]));
}
	objc_autoreleasePoolPop(pool);
}
@end

Modified tests/Makefile from [7aec6cf55a] to [4c633051dc].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
21
22
23
24
25
26
27

28
29
30
31
32
33
34







-







       OFValueTests.m			\
       OFXMLNodeTests.m			\
       OFXMLParserTests.m		\
       TestsAppDelegate.m		\
       ${USE_SRCS_FILES}		\
       ${USE_SRCS_SOCKETS}
SRCS_SOCKETS = ${OF_HTTP_CLIENT_TESTS_M}	\
	       OFHTTPCookieManagerTests.m	\
	       OFKernelEventObserverTests.m

IOS_USER ?= mobile
IOS_TMP ?= /tmp/objfw-test

include ../buildsys.mk

Modified tests/TestsAppDelegate.h from [659a8ae3e6] to [33a2e645a0].

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
67
68
69
70
71
72
73




74
75
76
77
78
79
80







-
-
-
-







- (void)dictionaryTests;
@end

@interface TestsAppDelegate (OFHTTPClientTests)
- (void)HTTPClientTests;
@end

@interface TestsAppDelegate (OFHTTPCookieManagerTests)
- (void)HTTPCookieManagerTests;
@end

@interface TestsAppDelegate (OFKernelEventObserverTests)
- (void)kernelEventObserverTests;
@end

@interface TestsAppDelegate (OFListTests)
- (void)listTests;
@end

Modified tests/TestsAppDelegate.m from [f4b3fadebd] to [fbab5e01e9].

378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
378
379
380
381
382
383
384



385
386
387
388
389
390
391







-
-
-







	[self memoryStreamTests];
#ifdef OF_HAVE_SOCKETS
	[self kernelEventObserverTests];
#endif
#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS)
	[self HTTPClientTests];
#endif
#ifdef OF_HAVE_SOCKETS
	[self HTTPCookieManagerTests];
#endif
	[self XMLParserTests];
	[self XMLNodeTests];

	[OFStdOut reset];

#if defined(OF_IOS)
	[OFStdOut writeFormat: @"%d tests failed!", _fails];