ObjFW  Diff

Differences From Artifact [2e9348ac5f]:

To Artifact [c2cad19355]:


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
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFHTTPCookie.h"




#import "OFAutoreleasePool.h"

#import "TestsAppDelegate.h"

static OFString *module = @"OFHTTPCookie";

@implementation TestsAppDelegate (OFHTTPCookieTests)
- (void)HTTPCookieTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

	OFHTTPCookie *cookie[2];

	cookie[0] = [OFHTTPCookie cookieWithName: @"foo"
					   value: @"bar"];

	TEST(@"+[cookiesForString:] #1",
	    [[OFHTTPCookie cookiesForString: @"foo=bar"] isEqual:


	    [OFArray arrayWithObject: cookie[0]]])

	cookie[1] = [OFHTTPCookie cookieWithName: @"qux"
					   value: @"cookie"];

	TEST(@"+[cookiesForString:] #2",

	    [[OFHTTPCookie cookiesForString: @"foo=bar,qux=cookie"] isEqual:

	    [OFArray arrayWithObjects: cookie[0], cookie[1], nil]])

	[cookie[0] setExpires:
	    [OFDate dateWithTimeIntervalSince1970: 1234567890]];
	[cookie[1] setExpires:
	    [OFDate dateWithTimeIntervalSince1970: 1234567890]];
	[cookie[0] setPath: @"/x"];
	[cookie[1] setDomain: @"heap.zone"];
	[cookie[1] setPath: @"/objfw"];
	[cookie[1] setSecure: true];
	[cookie[1] setHTTPOnly: true];
	[[cookie[1] extensions] addObject: @"foo"];
	[[cookie[1] extensions] addObject: @"bar"];
	TEST(@"+[cookiesForString:] #3",
	    [[OFHTTPCookie cookiesForString:

	    @"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=heap.zone; Path=/objfw; Secure; HTTPOnly; foo; bar"]

	    isEqual: [OFArray arrayWithObjects: cookie[0], cookie[1], nil]])

	[pool drain];
}
@end







>
>
>
>










>



|
>

|
>
>
|


|
>

>
|
>
|






|






|
>


|
>
|




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
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFHTTPCookie.h"
#import "OFArray.h"
#import "OFDate.h"
#import "OFDictionary.h"
#import "OFURL.h"
#import "OFAutoreleasePool.h"

#import "TestsAppDelegate.h"

static OFString *module = @"OFHTTPCookie";

@implementation TestsAppDelegate (OFHTTPCookieTests)
- (void)HTTPCookieTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFURL *URL = [OFURL URLWithString: @"http://heap.zone"];
	OFHTTPCookie *cookie[2];

	cookie[0] = [OFHTTPCookie cookieWithName: @"foo"
					   value: @"bar"
					  domain: @"heap.zone"];
	TEST(@"+[cookiesForString:] #1",
	    [[OFHTTPCookie cookiesFromHeaders: [OFDictionary
	    dictionaryWithObject: @"foo=bar"
	    forKey: @"Set-Cookie"] forURL: URL]
	    isEqual: [OFArray arrayWithObject: cookie[0]]])

	cookie[1] = [OFHTTPCookie cookieWithName: @"qux"
					   value: @"cookie"
					  domain: @"heap.zone"];
	TEST(@"+[cookiesForString:] #2",
	    [[OFHTTPCookie cookiesFromHeaders: [OFDictionary
	    dictionaryWithObject: @"foo=bar,qux=cookie"
	    forKey: @"Set-Cookie"] forURL: URL]
	    isEqual: [OFArray arrayWithObjects: cookie[0], cookie[1], nil]])

	[cookie[0] setExpires:
	    [OFDate dateWithTimeIntervalSince1970: 1234567890]];
	[cookie[1] setExpires:
	    [OFDate dateWithTimeIntervalSince1970: 1234567890]];
	[cookie[0] setPath: @"/x"];
	[cookie[1] setDomain: @"webkeks.org"];
	[cookie[1] setPath: @"/objfw"];
	[cookie[1] setSecure: true];
	[cookie[1] setHTTPOnly: true];
	[[cookie[1] extensions] addObject: @"foo"];
	[[cookie[1] extensions] addObject: @"bar"];
	TEST(@"+[cookiesForString:] #3",
	    [[OFHTTPCookie cookiesFromHeaders: [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"] forURL: URL] isEqual:
	    [OFArray arrayWithObjects: cookie[0], cookie[1], nil]])

	[pool drain];
}
@end