|
|
|
@ -5,16 +5,19 @@
|
|
|
|
|
#import "HttpRequestUtil.h"
|
|
|
|
|
#import "PreferencesUtil.h"
|
|
|
|
|
#import "SignalUtil.h"
|
|
|
|
|
#import "SGNKeychainUtil.h"
|
|
|
|
|
#import <UICKeyChainStore/UICKeyChainStore.h>
|
|
|
|
|
|
|
|
|
|
@implementation HttpRequestResponseTest
|
|
|
|
|
-(void) testRequestToInitiate {
|
|
|
|
|
[Environment setCurrent:testEnv];
|
|
|
|
|
[[[Environment getCurrent] preferences] setLocalNumberTo:[PhoneNumber phoneNumberFromE164:@"+19027778888"]];
|
|
|
|
|
[[[Environment getCurrent] preferences] setValueForKey:@"Password" toValue:@"shall_not_password"];
|
|
|
|
|
[SGNKeychainUtil setLocalNumberTo:[PhoneNumber phoneNumberFromE164:@"+19025555555"]];
|
|
|
|
|
[UICKeyChainStore setString:@"shall_not_password" forKey:@"Password"];
|
|
|
|
|
[[[Environment getCurrent] preferences] setValueForKey:@"PasswordCounter" toValue:@2357];
|
|
|
|
|
HttpRequest* h = [HttpRequest httpRequestToInitiateToRemoteNumber:[PhoneNumber phoneNumberFromE164:@"+19023334444"]];
|
|
|
|
|
test([[h method] isEqualToString:@"GET"]);
|
|
|
|
|
test([[h location] isEqualToString:@"/session/1/+19023334444"]);
|
|
|
|
|
NSLog(@"HTTP rep: %@", [h toHttp]);
|
|
|
|
|
test([[h toHttp] isEqualToString:@"GET /session/1/+19023334444 HTTP/1.0\r\nAuthorization: OTP KzE5MDI3Nzc4ODg4OmluQ3lLcE1ZaFRQS0ZwN3BITlN3bUxVMVpCTT06MjM1Nw==\r\n\r\n"]);
|
|
|
|
|
test([h isEqualToHttpRequest:[HttpRequest httpRequestFromData:[h serialize]]]);
|
|
|
|
|
}
|
|
|
|
@ -27,9 +30,9 @@
|
|
|
|
|
}
|
|
|
|
|
-(void) testRequestToRing {
|
|
|
|
|
[Environment setCurrent:testEnv];
|
|
|
|
|
[[[Environment getCurrent] preferences] setLocalNumberTo:[PhoneNumber phoneNumberFromE164:@"+19025555555"]];
|
|
|
|
|
[[[Environment getCurrent] preferences] setValueForKey:@"Password" toValue:@"shall_not_password"];
|
|
|
|
|
[[[Environment getCurrent] preferences] setValueForKey:@"PasswordCounter" toValue:@0];
|
|
|
|
|
[SGNKeychainUtil setLocalNumberTo:[PhoneNumber phoneNumberFromE164:@"+19025555555"]];
|
|
|
|
|
[UICKeyChainStore setString:@"shall_not_password" forKey:@"Password"];
|
|
|
|
|
[UICKeyChainStore setString:[@0 stringValue] forKey:@"PasswordCounter"];
|
|
|
|
|
HttpRequest* h = [HttpRequest httpRequestToRingWithSessionId:458847238];
|
|
|
|
|
test([[h method] isEqualToString:@"RING"]);
|
|
|
|
|
test([[h location] isEqualToString:@"/session/458847238"]);
|
|
|
|
|