ObjFW  Check-in [677b61582e]

Overview
Comment:Migrate OFHTTPCookieTests to ObjFWTest
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | objfwtest
Files: files | file ages | folders
SHA3-256: 677b61582ef184088dac32b9cac0386fd8e409db77fb099a0e535e7cc90160b3
User & Date: js on 2024-02-17 22:12:49
Other Links: branch diff | manifest | tags
Context
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
21:04
Migrate OFWindowsRegistryKeyTests to ObjFWTest check-in: 4682e8f902 user: js tags: objfwtest
Changes

Modified new_tests/Makefile from [020f00eed1] to [9151d329b2].

52
53
54
55
56
57
58

59
60
61
62
63
64
65
66
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_SUBPROCESSES}		\
       ${USE_SRCS_THREADS}		\
       ${USE_SRCS_WINDOWS}		\
       testfile_bin.m			\
       testfile_ini.m
SRCS_PLUGINS = OFPluginTests.m

SRCS_SOCKETS = OFDNSResolverTests.m	\
	       OFSocketTests.m		\
	       OFTCPSocketTests.m	\
	       OFUDPSocketTests.m	\
	       ${USE_SRCS_IPX}		\
	       ${USE_SRCS_UNIX_SOCKETS}	\
	       ${USE_SRCS_APPLETALK}
SRCS_APPLETALK = OFDDPSocketTests.m







>
|







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
       ${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}	\
	       ${USE_SRCS_APPLETALK}
SRCS_APPLETALK = OFDDPSocketTests.m

Renamed and modified tests/OFHTTPCookieTests.m [eb0c618283] to new_tests/OFHTTPCookieTests.m [ef1c0d2e2f].

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
 * 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"


static OFString *const module = @"OFHTTPCookie";


@implementation TestsAppDelegate (OFHTTPCookieTests)
- (void)HTTPCookieTests
{
	void *pool = objc_autoreleasePoolPush();
	OFIRI *IRI = [OFIRI IRIWithString: @"http://nil.im"];
	OFHTTPCookie *cookie1, *cookie2;
	OFArray OF_GENERIC(OFHTTPCookie *) *cookies;


	cookie1 = [OFHTTPCookie cookieWithName: @"foo"
					 value: @"bar"
					domain: @"nil.im"];
	TEST(@"+[cookiesWithResponseHeaderFields:forIRI:] #1",
	    [[OFHTTPCookie cookiesWithResponseHeaderFields: [OFDictionary
	    dictionaryWithObject: @"foo=bar"
	    forKey: @"Set-Cookie"] forIRI: IRI]


	    isEqual: [OFArray arrayWithObject: cookie1]])

	cookie2 = [OFHTTPCookie cookieWithName: @"qux"
					 value: @"cookie"
					domain: @"nil.im"];
	TEST(@"+[cookiesWithResponseHeaderFields:forIRI:] #2",
	    [[OFHTTPCookie cookiesWithResponseHeaderFields: [OFDictionary
	    dictionaryWithObject: @"foo=bar,qux=cookie"
	    forKey: @"Set-Cookie"] forIRI: IRI]


	    isEqual: [OFArray arrayWithObjects: cookie1, cookie2, nil]])

	cookie1.expires = [OFDate dateWithTimeIntervalSince1970: 1234567890];
	cookie2.expires = [OFDate dateWithTimeIntervalSince1970: 1234567890];
	cookie1.path = @"/x";
	cookie2.domain = @"webkeks.org";
	cookie2.path = @"/objfw";
	cookie2.secure = true;
	cookie2.HTTPOnly = true;
	[cookie2.extensions addObject: @"foo"];
	[cookie2.extensions addObject: @"bar"];
	TEST(@"+[cookiesWithResponseHeaderFields:forIRI:] #3",
	    [(cookies = [OFHTTPCookie cookiesWithResponseHeaderFields:
	    [OFDictionary dictionaryWithObject:
	    @"foo=bar; Expires=Fri, 13 Feb 2009 23:31:30 GMT; Path=/x,"


	    @"qux=cookie; Expires=Fri, 13 Feb 2009 23:31:30 GMT; "
	    @"Domain=webkeks.org; Path=/objfw; Secure; HTTPOnly; foo; bar"





	    forKey: @"Set-Cookie"] forIRI: IRI]) isEqual:


	    [OFArray arrayWithObjects: cookie1, cookie2, nil]])


	TEST(@"+[requestHeaderFieldsWithCookies:]",








	    [[OFHTTPCookie requestHeaderFieldsWithCookies: cookies] isEqual:

	    [OFDictionary dictionaryWithObject: @"foo=bar; qux=cookie"
					forKey: @"Cookie"]])

	objc_autoreleasePoolPop(pool);
}
@end







|
>

|
>

|
|

<

|
<
|
>
|
|
|
|
|
|
|
>
>
|

<
<
<
<
<
|
|
>
>
|










|
|
|
|
>
>
|
|
>
>
>
>
>
|
>
>
|
|
>
|
>
>
>
>
>
>
>
>
|
>

|
|
<
<

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
 * 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 "ObjFW.h"
#import "ObjFWTest.h"

@interface OFHTTPCookieTests: OTTestCase
@end

@implementation OFHTTPCookieTests
- (void)testCookiesWithResponseHeaderFieldsForIRI
{

	OFIRI *IRI = [OFIRI IRIWithString: @"http://nil.im"];
	OFHTTPCookie *cookie1 = [OFHTTPCookie cookieWithName: @"foo"

						       value: @"bar"
						      domain: @"nil.im"];
	OFHTTPCookie *cookie2 = [OFHTTPCookie cookieWithName: @"qux"
						       value: @"cookie"
						      domain: @"nil.im"];
	OFDictionary *headers;

	headers = [OFDictionary dictionaryWithObject: @"foo=bar"
					      forKey: @"Set-Cookie"];
	OTAssertEqualObjects(
	    [OFHTTPCookie cookiesWithResponseHeaderFields: headers forIRI: IRI],
	    [OFArray arrayWithObject: cookie1]);






	headers = [OFDictionary dictionaryWithObject: @"foo=bar,qux=cookie"
					      forKey: @"Set-Cookie"];
	OTAssertEqualObjects(
	    [OFHTTPCookie cookiesWithResponseHeaderFields: headers forIRI: IRI],
	    ([OFArray arrayWithObjects: cookie1, cookie2, nil]));

	cookie1.expires = [OFDate dateWithTimeIntervalSince1970: 1234567890];
	cookie2.expires = [OFDate dateWithTimeIntervalSince1970: 1234567890];
	cookie1.path = @"/x";
	cookie2.domain = @"webkeks.org";
	cookie2.path = @"/objfw";
	cookie2.secure = true;
	cookie2.HTTPOnly = true;
	[cookie2.extensions addObject: @"foo"];
	[cookie2.extensions addObject: @"bar"];

	headers = [OFDictionary
	    dictionaryWithObject: @"foo=bar; "
				  @"Expires=Fri, 13 Feb 2009 23:31:30 GMT; "
				  @"Path=/x,"
				  @"qux=cookie; "
				  @"Expires=Fri, 13 Feb 2009 23:31:30 GMT; "
				  @"Domain=webkeks.org; "
				  @"Path=/objfw; "
				  @"Secure; "
				  @"HTTPOnly; "
				  @"foo; "
				  @"bar"
			  forKey: @"Set-Cookie"];
	OTAssertEqualObjects(
	    [OFHTTPCookie cookiesWithResponseHeaderFields: headers forIRI: IRI],
	    ([OFArray arrayWithObjects: cookie1, cookie2, nil]));
}

- (void)testRequestHeaderFieldsWithCookies
{
	OFHTTPCookie *cookie1 = [OFHTTPCookie cookieWithName: @"foo"
						       value: @"bar"
						      domain: @"nil.im"];
	OFHTTPCookie *cookie2 = [OFHTTPCookie cookieWithName: @"qux"
						       value: @"cookie"
						      domain: @"nil.im"];

	OTAssertEqualObjects([OFHTTPCookie requestHeaderFieldsWithCookies:
	    ([OFArray arrayWithObjects: cookie1, cookie2, nil])],
	    [OFDictionary dictionaryWithObject: @"foo=bar; qux=cookie"
					forKey: @"Cookie"]);
}


@end

Modified tests/Makefile from [45af6145a4] to [7aec6cf55a].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
       OFValueTests.m			\
       OFXMLNodeTests.m			\
       OFXMLParserTests.m		\
       TestsAppDelegate.m		\
       ${USE_SRCS_FILES}		\
       ${USE_SRCS_SOCKETS}
SRCS_SOCKETS = ${OF_HTTP_CLIENT_TESTS_M}	\
	       OFHTTPCookieTests.m		\
	       OFHTTPCookieManagerTests.m	\
	       OFKernelEventObserverTests.m

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

include ../buildsys.mk







<







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 [dba04c9406] to [659a8ae3e6].

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
- (void)dictionaryTests;
@end

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

@interface TestsAppDelegate (OFHTTPCookieTests)
- (void)HTTPCookieTests;
@end

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

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







<
<
<
<







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

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

379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
#ifdef OF_HAVE_SOCKETS
	[self kernelEventObserverTests];
#endif
#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS)
	[self HTTPClientTests];
#endif
#ifdef OF_HAVE_SOCKETS
	[self HTTPCookieTests];
	[self HTTPCookieManagerTests];
#endif
	[self XMLParserTests];
	[self XMLNodeTests];

	[OFStdOut reset];








<







379
380
381
382
383
384
385

386
387
388
389
390
391
392
#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];