From 6468dcfd1a608fa71847dd2595bacf3c5f1eb389 Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Sat, 5 Mar 2016 16:13:44 +0000 Subject: [PATCH] use safer port numbers git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39461 72102866-910b-0410-8b05-ffd578937521 --- Tests/base/NSURL/Helpers/capture.m | 2 +- Tests/base/NSURL/Helpers/respond.m | 2 +- Tests/base/NSURL/test00.m | 12 +-- Tests/base/NSURL/test02.m | 4 +- .../Helpers/NSURLConnectionTest.h | 8 +- .../Helpers/NSURLConnectionTest.m | 6 +- .../NSURLConnection/Helpers/TestWebServer.h | 6 +- .../NSURLConnection/Helpers/TestWebServer.m | 68 ++++++++-------- .../Helpers/testTestWebServer.m | 52 +++++++------ Tests/base/NSURLConnection/test02.m | 10 +-- Tests/base/NSURLConnection/test03.m | 77 ++++++++++--------- Tests/base/NSURLConnection/test04.m | 10 +-- Tests/base/NSURLConnection/test05.m | 12 +-- Tests/base/NSURLHandle/Helpers/StatusServer.m | 4 +- Tests/base/NSURLHandle/test01.m | 6 +- 15 files changed, 141 insertions(+), 138 deletions(-) diff --git a/Tests/base/NSURL/Helpers/capture.m b/Tests/base/NSURL/Helpers/capture.m index cd32dbc46..9cdcf5c5e 100644 --- a/Tests/base/NSURL/Helpers/capture.m +++ b/Tests/base/NSURL/Helpers/capture.m @@ -58,7 +58,7 @@ isSecure = [[defs stringForKey: @"Secure"] boolValue]; - if (port == 0) port = 54321; + if (port == 0) port = 1234; file = [defs stringForKey: @"FileName"]; RETAIN(file); diff --git a/Tests/base/NSURL/Helpers/respond.m b/Tests/base/NSURL/Helpers/respond.m index 1bd3dfdaa..c1345a608 100644 --- a/Tests/base/NSURL/Helpers/respond.m +++ b/Tests/base/NSURL/Helpers/respond.m @@ -40,7 +40,7 @@ NSString *file; int port = [[defs stringForKey: @"Port"] intValue]; - if (port == 0) port = 54321; + if (port == 0) port = 1234; count = [[defs stringForKey: @"Count"] intValue]; if (count <= 0) count = 1; diff --git a/Tests/base/NSURL/test00.m b/Tests/base/NSURL/test00.m index eb0f8b7c2..670dd1d01 100644 --- a/Tests/base/NSURL/test00.m +++ b/Tests/base/NSURL/test00.m @@ -30,7 +30,7 @@ int main() arguments: [NSArray arrayWithObjects: @"-FileName", @"Chunked.dat", @"-FileHdrs", @"YES", // Headers are in file - @"-Port", @"54321", + @"-Port", @"1234", @"-Count", @"1", nil]]; if (t != nil) @@ -43,7 +43,7 @@ int main() // Pause to allow server subtask to set up. [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.5]]; - u = [NSURL URLWithString: @"http://localhost:54321/chunked"]; + u = [NSURL URLWithString: @"http://localhost:1234/chunked"]; // Talk to server. data = [u resourceDataUsingCache: NO]; // Get status code @@ -58,7 +58,7 @@ int main() arguments: [NSArray arrayWithObjects: @"-FileName", @"Chunked.dat", @"-FileHdrs", @"YES", // Headers are in file - @"-Port", @"54321", + @"-Port", @"1234", @"-Count", @"1", nil]]; if (t != nil) @@ -74,7 +74,7 @@ int main() // Pause to allow server subtask to set up. [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.5]]; - u = [NSURL URLWithString: @"http://localhost:54321/chunked"]; + u = [NSURL URLWithString: @"http://localhost:1234/chunked"]; request = [NSURLRequest requestWithURL: u]; response = nil; @@ -91,7 +91,7 @@ int main() [t waitUntilExit]; } - url = [NSURL URLWithString: @"http://localhost:54321/"]; + url = [NSURL URLWithString: @"http://localhost:1234/"]; /* Ask the 'respond' helper to send back a response containing * 'hello' and to shrink the write buffer size it uses on each @@ -134,7 +134,7 @@ int main() * that loads work when handles are flushed from the cache. */ u = [NSURL URLWithString: [NSString stringWithFormat: - @"http://localhost:54321/%d", i % 18]]; + @"http://localhost:1234/%d", i % 18]]; // Talk to server. data = [u resourceDataUsingCache: NO]; // Get status code diff --git a/Tests/base/NSURL/test02.m b/Tests/base/NSURL/test02.m index 080d149e3..f522a49bd 100644 --- a/Tests/base/NSURL/test02.m +++ b/Tests/base/NSURL/test02.m @@ -44,7 +44,7 @@ int main() // remove the captured data from a possible previous run [fm removeItemAtPath: file error: NULL]; // making a POST request - url = [NSURL URLWithString: @"http://localhost:54321/"]; + url = [NSURL URLWithString: @"http://localhost:1234/"]; request = [NSMutableURLRequest requestWithURL: url]; data = [m dataUsingEncoding: NSUTF8StringEncoding]; [request setHTTPBody: data]; @@ -86,7 +86,7 @@ int main() // remove the captured data from a possible previous run [fm removeItemAtPath: file error: NULL]; // making a POST request - url = [NSURL URLWithString: @"https://localhost:54321/"]; + url = [NSURL URLWithString: @"https://localhost:1234/"]; request = [NSMutableURLRequest requestWithURL: url]; data = [m dataUsingEncoding: NSUTF8StringEncoding]; [request setHTTPBody: data]; diff --git a/Tests/base/NSURLConnection/Helpers/NSURLConnectionTest.h b/Tests/base/NSURLConnection/Helpers/NSURLConnectionTest.h index 05c70e64f..eb31d0a50 100644 --- a/Tests/base/NSURLConnection/Helpers/NSURLConnectionTest.h +++ b/Tests/base/NSURLConnection/Helpers/NSURLConnectionTest.h @@ -13,7 +13,7 @@ * test. * * The test case which the NSURLConnectionTest implements by default is connecting - * to the http://localhost:54321/ whith the HTTP method 'GET'. You can change variable + * to the http://127.0.0.1:1234/ whith the HTTP method 'GET'. You can change variable * parts of process by supplying a custom dictionary to the method -[setUpTest:] * before the test case is started by a call of the -[startTest:]. The use pattern: * -------------------------------------------------------------------------- @@ -57,12 +57,12 @@ * (the instance will be run within a detached thread). * Default: NO * 'Address' - the address of the remote side. - * Default: localhost + * Default: 127.0.0.1 * 'Port' - the port of the remote side. - * Default: 54321 + * Default: 1234 * 'AuxPort' - the port of the auxilliary remote side (where the connection * to be redirected). - * Default: 54322 + * Default: 1235 * 'Protocol' - the network protocol (supports currently http, https). * Default: http * 'Path' - the path of the URL. diff --git a/Tests/base/NSURLConnection/Helpers/NSURLConnectionTest.m b/Tests/base/NSURLConnection/Helpers/NSURLConnectionTest.m index b4cc6d044..c9113a50b 100644 --- a/Tests/base/NSURLConnection/Helpers/NSURLConnectionTest.m +++ b/Tests/base/NSURLConnection/Helpers/NSURLConnectionTest.m @@ -583,15 +583,15 @@ didReceiveResponse:(NSURLResponse *)response } if (nil == address) { - address = @"localhost"; + address = @"127.0.0.1"; } if (nil == port) { - port = @"54321"; + port = @"1234"; } if (nil == auxPort) { - auxPort = @"54322"; + auxPort = @"1235"; } if (nil == path) { diff --git a/Tests/base/NSURLConnection/Helpers/TestWebServer.h b/Tests/base/NSURLConnection/Helpers/TestWebServer.h index efc1b153c..a7dd90803 100644 --- a/Tests/base/NSURLConnection/Helpers/TestWebServer.h +++ b/Tests/base/NSURLConnection/Helpers/TestWebServer.h @@ -13,7 +13,7 @@ * It is designed to call the delegate's callbacks (if implemented) of * the TestWebServerDelegate protocol for every request made to * the SimpleWebServer's assigned address on the SimpleWebServer's assigned port - * (by default 127.0.0.1 and 54321 respectively). However it currently doesn't + * (by default 127.0.0.1 and 1234 respectively). However it currently doesn't * handle any request on it's own. Instead the class uses a collection of * handlers. Every handler makes a custom response. So the TestWebServer only * has to dispatch a request to a corresponding handler and then to send back @@ -30,7 +30,7 @@ * @"https", @"Protocol", * nil]; * TestWebServer *server = [[TestWebServer alloc] initWithAddress: @"127.0.0.1" - * port: @"54321" + * port: @"1234" * mode: NO * extra: extra]; * ADelegateClass *del = [ADelegateClass new]; @@ -72,7 +72,7 @@ * 301 "Redirect to " * Returns in the header 'Location' a new which by default * has the same protocol, address but the port is incremented by - * 1 (e.g. http://localhost:54322/ with other parameters set to + * 1 (e.g. http://127.0.0.1:1235/ with other parameters set to * their default values). * 400 "You have issued a request with invalid data" * 401 "Invalid login or password" diff --git a/Tests/base/NSURLConnection/Helpers/TestWebServer.m b/Tests/base/NSURLConnection/Helpers/TestWebServer.m index c0e89d225..34fcbc881 100644 --- a/Tests/base/NSURLConnection/Helpers/TestWebServer.m +++ b/Tests/base/NSURLConnection/Helpers/TestWebServer.m @@ -27,7 +27,7 @@ /* default 'constants' */ #define DEFAULTADDRESS @"127.0.0.1" -#define DEFAULTPORT @"54321" +#define DEFAULTPORT @"1234" #define DEFAULTMODE NO #define DEFAULTLOGIN @"login" #define DEFAULTPASSWORD @"password" @@ -58,7 +58,7 @@ mode:(BOOL)detached extra:(id)extra { - if((self = [super init]) != nil) + if ((self = [super init]) != nil) { _debug = NO; _address = [[NSHost hostWithName: address] address]; @@ -69,31 +69,31 @@ _login = nil; _isSecure = NO; - if([extra isKindOfClass: [NSDictionary class]]) + if ([extra isKindOfClass: [NSDictionary class]]) { NSDictionary *d = extra; NSString *proto; - if((_password = [d objectForKey: @"Password"]) != nil) + if ((_password = [d objectForKey: @"Password"]) != nil) { RETAIN(_password); } - if((_login = [d objectForKey: @"Login"]) != nil) + if ((_login = [d objectForKey: @"Login"]) != nil) { RETAIN(_login); } - if((proto = [d objectForKey: @"Protocol"]) != nil && + if ((proto = [d objectForKey: @"Protocol"]) != nil && [[proto lowercaseString] isEqualToString: @"https"]) { _isSecure = YES; } } - if(nil == _login) + if (nil == _login) { _login = DEFAULTLOGIN; RETAIN(_login); } - if(nil == _password) + if (nil == _password) { _password = DEFAULTPASSWORD; RETAIN(_password); } @@ -117,7 +117,7 @@ _lock = [[NSConditionLock alloc] initWithCondition: READY]; _threadToQuit = NO; - if(detached) + if (detached) { _serverThread = [[NSThread alloc] initWithTarget: self selector: @selector(_startDetached:) @@ -147,18 +147,18 @@ - (void)start:(id)extra { - if([_server port] != nil) + if ([_server port] != nil) { - if(YES == _debug) + if (YES == _debug) { NSWarnMLog(@"SimpleWebServer already started"); } return; } - if(nil != _serverThread) + if (nil != _serverThread) { - if(![_serverThread isExecuting]) + if (![_serverThread isExecuting]) { NSTimeInterval duration = 0.0; [_serverThread start]; @@ -172,7 +172,7 @@ duration += TIMING; } [_lock unlock]; - if(duration >= MAXDURATION && + if (duration >= MAXDURATION && nil != _delegate && [_delegate respondsToSelector: @selector(timeoutExceededByHandler:)]) { @@ -193,17 +193,17 @@ - (void)stop { - if([_server port] == nil) + if ([_server port] == nil) { - if(YES == _debug) + if (YES == _debug) { NSWarnMLog(@"SimpleWebServer already stopped"); } return; } - if(nil != _serverThread) + if (nil != _serverThread) { - if([_serverThread isExecuting]) + if ([_serverThread isExecuting]) { NSTimeInterval duration = 0.0; _threadToQuit = YES; // this makes the detached thread quiting from it's runloop @@ -217,7 +217,7 @@ duration += TIMING; } [_lock unlockWithCondition: READY]; - if(duration >= MAXDURATION && + if (duration >= MAXDURATION && nil != _delegate && [_delegate respondsToSelector: @selector(timeoutExceededByHandler:)]) { @@ -248,21 +248,21 @@ en = [[path pathComponents] objectEnumerator]; while((component = [en nextObject]) != nil) { - if((handler = [_traversalMap objectForKey: component]) != nil) + if ((handler = [_traversalMap objectForKey: component]) != nil) { // the handler has been found break; // while } } - if(nil == component) + if (nil == component) { // no component found... default 204 component = @"204"; handler = [_traversalMap objectForKey: component]; } - if(handler == [handler class]) + if (handler == [handler class]) { // it is a Class not an instance... instantiate and substitute // instead of the Class @@ -275,9 +275,9 @@ [handler setDelegate: _delegate]; [handler setLogin: _login]; [handler setPassword: _password]; - if([handler respondsToSelector: @selector(setURLString:)]) + if ([handler respondsToSelector: @selector(setURLString:)]) { - if([handler isKindOfClass: [HandlerIndex class]]) + if ([handler isKindOfClass: [HandlerIndex class]]) { NSString *urlString = [NSString stringWithFormat: @"%@://%@:%@/", _isSecure ? @"https" : @"http", @@ -286,9 +286,9 @@ [(HandlerIndex *)handler setURLString: urlString]; } - else if([handler isKindOfClass: [Handler301 class]]) + else if ([handler isKindOfClass: [Handler301 class]]) { - // by default http://localhost:54322/ + // by default http://127.0.0.1:1235/ NSString *port = [NSString stringWithFormat: @"%u", [_port intValue] + 1]; // the TestWebServer's port + 1 NSString *urlString = [NSString stringWithFormat: @"%@://%@:%@/", _isSecure ? @"https" : @"http", @@ -379,9 +379,9 @@ _server = [SimpleWebServer new]; [_server setDebug: _debug]; [_server setDelegate: self]; - if(_isSecure) + if (_isSecure) { - if([_address isEqualToString: @"127.0.0.1"] || + if ([_address isEqualToString: @"127.0.0.1"] || [_address isEqualToString: @"localhost"]) { certPath = [[NSBundle bundleForClass: [self class]] @@ -403,7 +403,7 @@ } status = [_server setAddress: _address port: _port secure: secure]; // run the server - if(!status) + if (!status) { [NSException raise: NSInternalInconsistencyException format: @"The server hasn't run. Perhaps the port %@ is invalid", DEFAULTPORT]; @@ -412,10 +412,10 @@ - (void)_stopHTTPServer { - if(nil != _server && [_server port] != nil) + if (nil != _server && [_server port] != nil) { [_server stop]; // shut down the server - if(YES == _debug) + if (YES == _debug) { NSLog(@"%@: stopped SimpleWebServer %@", self, _server); } @@ -432,7 +432,7 @@ [self _startHTTPServer: extra]; [_lock unlockWithCondition: STARTED]; - if(YES == _debug) + if (YES == _debug) { NSLog(@"%@: enter into runloop in detached thread %@", self, [NSThread currentThread]); } @@ -444,12 +444,12 @@ duration += TIMING; } - if(YES == _debug) + if (YES == _debug) { NSLog(@"%@: exit from runloop in detached thread %@", self, [NSThread currentThread]); } - if(duration >= MAXDURATION && + if (duration >= MAXDURATION && nil != _delegate && [_delegate respondsToSelector: @selector(timeoutExceededByHandler:)]) { diff --git a/Tests/base/NSURLConnection/Helpers/testTestWebServer.m b/Tests/base/NSURLConnection/Helpers/testTestWebServer.m index 9b4d27206..1820926d4 100644 --- a/Tests/base/NSURLConnection/Helpers/testTestWebServer.m +++ b/Tests/base/NSURLConnection/Helpers/testTestWebServer.m @@ -3,25 +3,25 @@ * Author: Sergei Golovin * * Runs two TestWebServer instances to check how the class TestWebServer - * behaves. Visit http://localhost:54321/index to see all supported resources. + * behaves. Visit http://127.0.0.1:1234/index to see all supported resources. * * If you visit the main TestWebServer instance with the following command: * - * wget -O - --user=login --password=password http://localhost:54321/301 2>&1 + * wget -O - --user=login --password=password http://127.0.0.1:1234/301 2>&1 * * you should get a session log like this: * - * --2014-08-13 12:08:01-- http://localhost:54321/301 - * Resolving localhost (localhost)... 127.0.0.1 - * Connecting to localhost (localhost)|127.0.0.1|:54321... connected. + * --2014-08-13 12:08:01-- http://127.0.0.1:1234/301 + * Resolving 127.0.0.1 (localhost)... 127.0.0.1 + * Connecting to 127.0.0.1 (localhost)|127.0.0.1|:1234... connected. * HTTP request sent, awaiting response... 401 Unauthorized - * Reusing existing connection to localhost:54321. + * Reusing existing connection to 127.0.0.1:1234. * HTTP request sent, awaiting response... 301 Moved Permanently - * Location: http://127.0.0.1:54322/ [following] - * --2014-08-13 12:08:01-- http://127.0.0.1:54322/ - * Connecting to 127.0.0.1:54322... connected. + * Location: http://127.0.0.1:1235/ [following] + * --2014-08-13 12:08:01-- http://127.0.0.1:1235/ + * Connecting to 127.0.0.1:1235... connected. * HTTP request sent, awaiting response... 401 Unauthorized - * Reusing existing connection to 127.0.0.1:54322. + * Reusing existing connection to 127.0.0.1:1235. * HTTP request sent, awaiting response... 204 No Content * Length: 0 * Saving to: ‘STDOUT’ @@ -47,11 +47,11 @@ int main(int argc, char **argv, char **env) fm = [NSFileManager defaultManager]; helperPath = [[fm currentDirectoryPath] - stringByAppendingString: @"/TestConnection.bundle"]; + stringByAppendingString: @"/TestConnection.bundle"]; bundle = [NSBundle bundleWithPath: helperPath]; loaded = [bundle load]; - if(loaded) + if (loaded) { TestWebServer *server1; TestWebServer *server2; @@ -61,23 +61,25 @@ int main(int argc, char **argv, char **env) testClass = [bundle principalClass]; // NSURLConnectionTest d = [NSDictionary dictionaryWithObjectsAndKeys: - // @"https", @"Protocol", - nil]; - server1 = [[[testClass testWebServerClass] alloc] initWithAddress: @"localhost" - port: @"54321" - mode: NO - extra: d]; + // @"https", @"Protocol", + nil]; + server1 = [[[testClass testWebServerClass] alloc] + initWithAddress: @"127.0.0.1" + port: @"1234" + mode: NO + extra: d]; [server1 setDebug: debug]; - [server1 start: d]; // 127.0.0.1:54321 HTTP + [server1 start: d]; // 127.0.0.1:1234 HTTP - server2 = [[[testClass testWebServerClass] alloc] initWithAddress: @"localhost" - port: @"54322" - mode: NO - extra: d]; + server2 = [[[testClass testWebServerClass] alloc] + initWithAddress: @"127.0.0.1" + port: @"1235" + mode: NO + extra: d]; [server2 setDebug: debug]; - [server2 start: d]; // 127.0.0.1:54322 HTTP + [server2 start: d]; // 127.0.0.1:1235 HTTP - while(YES) + while (YES) { [[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: TIMING]]; diff --git a/Tests/base/NSURLConnection/test02.m b/Tests/base/NSURLConnection/test02.m index de7f2e81f..4238a360a 100644 --- a/Tests/base/NSURLConnection/test02.m +++ b/Tests/base/NSURLConnection/test02.m @@ -35,7 +35,7 @@ int main(int argc, char **argv, char **env) // create a shared TestWebServer instance for performance server = [[testClass testWebServerClass] new]; [server setDebug: debug]; - [server start: nil]; // 127.0.0.1:54321 HTTP + [server start: nil]; // 127.0.0.1:1234 HTTP /* * Simple GET via HTTP with empty response's body and @@ -49,7 +49,7 @@ int main(int argc, char **argv, char **env) nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "GET http://localhost:54321"); + PASS([testCase isSuccess], "GET http://localhost:1234/"); [testCase tearDownTest: d]; DESTROY(testCase); @@ -68,7 +68,7 @@ int main(int argc, char **argv, char **env) nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "response 400 .... GET http://localhost:54321/400"); + PASS([testCase isSuccess], "response 400 .... GET http://localhost:1234/400"); [testCase tearDownTest: d]; DESTROY(testCase); @@ -89,7 +89,7 @@ int main(int argc, char **argv, char **env) nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "payload... response 400 .... POST http://localhost:54321/400"); + PASS([testCase isSuccess], "payload... response 400 .... POST http://localhost:1234/400"); [testCase tearDownTest: d]; DESTROY(testCase); @@ -115,7 +115,7 @@ int main(int argc, char **argv, char **env) nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "redirecting... GET http://localhost:54321/301"); + PASS([testCase isSuccess], "redirecting... GET http://localhost:1234/301"); [testCase tearDownTest: d]; DESTROY(testCase); diff --git a/Tests/base/NSURLConnection/test03.m b/Tests/base/NSURLConnection/test03.m index 06d5bf77f..e81fa746b 100644 --- a/Tests/base/NSURLConnection/test03.m +++ b/Tests/base/NSURLConnection/test03.m @@ -19,11 +19,11 @@ int main(int argc, char **argv, char **env) // load the test suite's classes fm = [NSFileManager defaultManager]; helperPath = [[fm currentDirectoryPath] - stringByAppendingString: @"/Helpers/TestConnection.bundle"]; + stringByAppendingString: @"/Helpers/TestConnection.bundle"]; bundle = [NSBundle bundleWithPath: helperPath]; loaded = [bundle load]; - if(loaded) + if (loaded) { NSDictionary *d; Class testClass; @@ -36,15 +36,16 @@ int main(int argc, char **argv, char **env) // the extra dictionary commanding to use HTTPS d = [NSDictionary dictionaryWithObjectsAndKeys: - @"HTTPS", @"Protocol", - nil]; + @"HTTPS", @"Protocol", + nil]; // create a shared TestWebServer instance for performance - server = [[[testClass testWebServerClass] alloc] initWithAddress: @"localhost" - port: @"54321" - mode: NO - extra: d]; + server = [[[testClass testWebServerClass] alloc] + initWithAddress: @"127.0.0.1" + port: @"1234" + mode: NO + extra: d]; [server setDebug: debug]; - [server start: d]; // 127.0.0.1:54321 HTTPS + [server start: d]; // 127.0.0.1:1234 HTTPS /* * Simple GET via HTTPS with empty response's body and @@ -54,11 +55,11 @@ int main(int argc, char **argv, char **env) [testCase setDebug: debug]; // the extra dictionary with test case's parameters d = [NSDictionary dictionaryWithObjectsAndKeys: - server, @"Instance", // we use the shared TestWebServer instance - nil]; + server, @"Instance", // we use the shared TestWebServer instance + nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "HTTPS... GET https://localhost:54321"); + PASS([testCase isSuccess], "HTTPS... GET https://127.0.0.1:1234/"); [testCase tearDownTest: d]; DESTROY(testCase); @@ -70,14 +71,14 @@ int main(int argc, char **argv, char **env) [testCase setDebug: debug]; // the extra dictionary with test case's parameters d = [NSDictionary dictionaryWithObjectsAndKeys: - server, @"Instance", // we use the shared TestWebServer instance - @"400", @"Path", // request the handler responding with 400 - @"400", @"StatusCode", // the expected status code - @"You have issued a request with invalid data", @"Content", // the expected response's body - nil]; + server, @"Instance", // we use the shared TestWebServer instance + @"400", @"Path", // request the handler responding with 400 + @"400", @"StatusCode", // the expected status code + @"You have issued a request with invalid data", @"Content", + nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "HTTPS... response 400 .... GET https://localhost:54321/400"); + PASS([testCase isSuccess], "HTTPS... response 400 .... GET https://localhost:1234/400"); [testCase tearDownTest: d]; DESTROY(testCase); @@ -89,16 +90,16 @@ int main(int argc, char **argv, char **env) [testCase setDebug: debug]; // the extra dictionary with test case's parameters d = [NSDictionary dictionaryWithObjectsAndKeys: - server, @"Instance", // we use the shared TestWebServer instance - @"400", @"Path", // request the handler responding with 400 - @"400", @"StatusCode", // the expected status code - @"You have issued a request with invalid data", @"Content", // the expected response's body - @"Some payload", @"Payload", // the custom payload - @"POST", @"Method", // use POST - nil]; + server, @"Instance", // we use the shared TestWebServer instance + @"400", @"Path", // request the handler responding with 400 + @"400", @"StatusCode", // the expected status code + @"You have issued a request with invalid data", @"Content", + @"Some payload", @"Payload", // the custom payload + @"POST", @"Method", // use POST + nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "HTTPS... payload... response 400 .... POST https://localhost:54321/400"); + PASS([testCase isSuccess], "HTTPS... payload... response 400 .... POST https://localhost:1234/400"); [testCase tearDownTest: d]; DESTROY(testCase); @@ -112,19 +113,19 @@ int main(int argc, char **argv, char **env) [testCase setDebug: debug]; // the reference set difference (from the default reference set) we expect refs = [NSDictionary dictionaryWithObjectsAndKeys: - @"YES", @"GOTREDIRECT", - nil]; - // the extra dictionary with test case's parameters - d = [NSDictionary dictionaryWithObjectsAndKeys: - server, @"Instance", // we use the shared TestWebServer instance - @"/301", @"Path", // request the handler responding with a redirect - @"/", @"RedirectPath", // the URL's path of redirecting - @"YES", @"IsAuxilliary", // start an auxilliary TestWebServer instance - refs, @"ReferenceFlags", // the expected reference set difference - nil]; + @"YES", @"GOTREDIRECT", + nil]; + // the extra dictionary with test case's parameters + d = [NSDictionary dictionaryWithObjectsAndKeys: + server, @"Instance", // we use the shared TestWebServer instance + @"/301", @"Path", // request the handler responding with a redirect + @"/", @"RedirectPath", // the URL's path of redirecting + @"YES", @"IsAuxilliary", // start an auxilliary TestWebServer instance + refs, @"ReferenceFlags", // the expected reference set difference + nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "HTTPS... redirecting... GET https://localhost:54321/301"); + PASS([testCase isSuccess], "HTTPS... redirecting... GET https://localhost:1234/301"); [testCase tearDownTest: d]; DESTROY(testCase); @@ -136,7 +137,7 @@ int main(int argc, char **argv, char **env) { // no classes no tests [NSException raise: NSInternalInconsistencyException - format: @"can't load bundle TestConnection"]; + format: @"can't load bundle TestConnection"]; } DESTROY(arp); diff --git a/Tests/base/NSURLConnection/test04.m b/Tests/base/NSURLConnection/test04.m index 4270b371f..b0c26ae8a 100644 --- a/Tests/base/NSURLConnection/test04.m +++ b/Tests/base/NSURLConnection/test04.m @@ -35,7 +35,7 @@ int main(int argc, char **argv, char **env) // create a shared TestWebServer instance for performance server = [[testClass testWebServerClass] new]; [server setDebug: debug]; - [server start: nil]; // 127.0.0.1:54321 HTTP + [server start: nil]; // 127.0.0.1:1234 HTTP /* * Simple GET via HTTP without authorization with empty response's body and @@ -59,7 +59,7 @@ int main(int argc, char **argv, char **env) nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "no auth... GET http://localhost:54321/withoutauth"); + PASS([testCase isSuccess], "no auth... GET http://localhost:1234/withoutauth"); [testCase tearDownTest: d]; DESTROY(testCase); @@ -87,7 +87,7 @@ int main(int argc, char **argv, char **env) nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "no auth... response 400 .... GET http://localhost:54321/400/withoutauth"); + PASS([testCase isSuccess], "no auth... response 400 .... GET http://localhost:1234/400/withoutauth"); [testCase tearDownTest: d]; DESTROY(testCase); @@ -117,7 +117,7 @@ int main(int argc, char **argv, char **env) nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "no auth... payload... response 400 .... POST http://localhost:54321/400/withoutauth"); + PASS([testCase isSuccess], "no auth... payload... response 400 .... POST http://localhost:1234/400/withoutauth"); [testCase tearDownTest: d]; DESTROY(testCase); @@ -148,7 +148,7 @@ int main(int argc, char **argv, char **env) nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "no auth... redirecting... GET http://localhost:54321/301/withoutauth"); + PASS([testCase isSuccess], "no auth... redirecting... GET http://localhost:1234/301/withoutauth"); [testCase tearDownTest: d]; DESTROY(testCase); diff --git a/Tests/base/NSURLConnection/test05.m b/Tests/base/NSURLConnection/test05.m index bfc09e642..94924392a 100644 --- a/Tests/base/NSURLConnection/test05.m +++ b/Tests/base/NSURLConnection/test05.m @@ -39,11 +39,11 @@ int main(int argc, char **argv, char **env) nil]; // create a shared TestWebServer instance for performance server = [[[testClass testWebServerClass] alloc] initWithAddress: @"localhost" - port: @"54321" + port: @"1234" mode: NO extra: d]; [server setDebug: debug]; - [server start: d]; // 127.0.0.1:54321 HTTPS + [server start: d]; // 127.0.0.1:1234 HTTPS /* * Simple GET via HTTPS without authorization with empty response's body and @@ -67,7 +67,7 @@ int main(int argc, char **argv, char **env) nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "HTTPS... no auth...GET https://localhost:54321/withoutauth"); + PASS([testCase isSuccess], "HTTPS... no auth...GET https://localhost:1234/withoutauth"); [testCase tearDownTest: d]; DESTROY(testCase); @@ -95,7 +95,7 @@ int main(int argc, char **argv, char **env) nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "HTTPS... no auth... response 400... GET https://localhost:54321/400/withoutauth"); + PASS([testCase isSuccess], "HTTPS... no auth... response 400... GET https://localhost:1234/400/withoutauth"); [testCase tearDownTest: d]; DESTROY(testCase); @@ -125,7 +125,7 @@ int main(int argc, char **argv, char **env) nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "HTTPS... no auth... payload... response 400 .... POST https://localhost:54321/400/withoutauth"); + PASS([testCase isSuccess], "HTTPS... no auth... payload... response 400 .... POST https://localhost:1234/400/withoutauth"); [testCase tearDownTest: d]; DESTROY(testCase); @@ -156,7 +156,7 @@ int main(int argc, char **argv, char **env) nil]; [testCase setUpTest: d]; [testCase startTest: d]; - PASS([testCase isSuccess], "HTTPS... no auth... redirecting... GET https://localhost:54321/301/withoutauth"); + PASS([testCase isSuccess], "HTTPS... no auth... redirecting... GET https://localhost:1234/301/withoutauth"); [testCase tearDownTest: d]; DESTROY(testCase); diff --git a/Tests/base/NSURLHandle/Helpers/StatusServer.m b/Tests/base/NSURLHandle/Helpers/StatusServer.m index c16bf1431..ce38f2c9f 100644 --- a/Tests/base/NSURLHandle/Helpers/StatusServer.m +++ b/Tests/base/NSURLHandle/Helpers/StatusServer.m @@ -2,8 +2,8 @@ #if GNUSTEP -#define PORT_LISTEN 54321 -#define LOCATION200 @"http://localhost:54321/200" +#define PORT_LISTEN 1234 +#define LOCATION200 @"http://localhost:1234/200" @interface StatusServer : NSObject { diff --git a/Tests/base/NSURLHandle/test01.m b/Tests/base/NSURLHandle/test01.m index a94aeef8c..d65315016 100644 --- a/Tests/base/NSURLHandle/test01.m +++ b/Tests/base/NSURLHandle/test01.m @@ -22,7 +22,7 @@ int main(int argc, char **argv) NSData *resp; NSData *rxd; - url = [NSURL URLWithString: @"http://localhost:54321/200"]; + url = [NSURL URLWithString: @"http://localhost:1234/200"]; cls = [NSURLHandle URLHandleClassForURL: url]; resp = [NSData dataWithBytes: "Hello\r\n" length: 7]; @@ -45,13 +45,13 @@ int main(int argc, char **argv) PASS([handle status] == NSURLHandleLoadSucceeded, "200 - status: Handle load succeeded") ; - url = [NSURL URLWithString: @"http://localhost:54321/401"]; + url = [NSURL URLWithString: @"http://localhost:1234/401"]; handle = [[[cls alloc] initWithURL: url cached: NO] autorelease]; rxd = [handle loadInForeground]; PASS([handle status] == NSURLHandleNotLoaded, "401 - status: Handle load not loaded (unanswered auth challenge)"); - url = [NSURL URLWithString: @"http://localhost:54321/404"]; + url = [NSURL URLWithString: @"http://localhost:1234/404"]; handle = [[[cls alloc] initWithURL: url cached: NO] autorelease]; rxd = [handle loadInForeground]; PASS([handle status] == NSURLHandleNotLoaded,