Permalink
Browse files

Fixed tests and minor changes to share url decoding

  • Loading branch information...
1 parent 6c5cac4 commit 191cf23ef5037ce2523444be2494ec635deddca0 @davidchiles davidchiles committed Jun 23, 2016
View
@@ -24,4 +24,4 @@ before_script:
- export COCOAPODS_DISABLE_DETERMINISTIC_UUIDS=1 # https://github.com/CocoaPods/CocoaPods/issues/3850
- pod install
script:
- - xctool -workspace ChatSecure.xcworkspace -scheme ChatSecure -sdk iphonesimulator -arch i386 build
+ - xctool -workspace ChatSecure.xcworkspace -scheme ChatSecureTests -sdk iphonesimulator -arch i386 test
@@ -31,15 +31,13 @@
* @param baseURL the base url that the username and fingerprint will be added to
* @param username the username of your own account
* @param fingerprints the users fingerprints. key=OTRFingerprintType->NSString, value=fingerprintSTring
- * @param base64Encoded whether to base64 encode the last path component
* @return a url that is shareable
*
* @see +fingerprintStringTypeForFingerprintType:
*/
+ (NSURL*) otr_shareLink:(NSString *)baseURL
username:(NSString *)username
- fingerprints:(NSDictionary <NSString*, NSString*> *)fingerprints
- base64Encoded:(BOOL)base64Encoded;
+ fingerprints:(NSDictionary <NSString*, NSString*> *)fingerprints;
/**
* Synchronously decodes a url into the given username and fingerprint.
@@ -61,11 +61,11 @@ + (NSURL*) otr_shareBaseURL {
*/
+ (NSURL*) otr_shareLink:(NSString *)baseURL
username:(NSString *)username
- fingerprints:(NSDictionary <NSString*, NSString*> *)fingerprints
- base64Encoded:(BOOL)base64Encoded {
+ fingerprints:(NSDictionary <NSString*, NSString*> *)fingerprints {
NSParameterAssert(baseURL);
NSParameterAssert(username);
NSString *urlString = @"";
+ BOOL base64Encoded = YES;
NSMutableString *fingerprintsString = [NSMutableString string];
@@ -138,8 +138,8 @@ - (void)otr_decodeShareLink:(void (^)(NSString *username, NSString *fingerprint)
NSString *utf8String = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
components = [utf8String componentsSeparatedByString:@"?otr="];
- if (components.count == 0) {
- completion(utf8String, nil);
+ if (components.count == 1) {
+ completion(components.firstObject, nil);
} else if (components.count == 2) {
completion(components.firstObject, components.lastObject);
} else {
@@ -253,7 +253,7 @@ - (void) generateShareURLWithFingerprintTypes:(NSSet <NSNumber*> *)fingerprintTy
// Since we only support OTR at the moment, we can finish here, but this should be refactored with a dispatch_group when we support more key types.
- NSURL *url = [NSURL otr_shareLink:baseURL.absoluteString username:self.username fingerprints:fingerprints base64Encoded:YES];
+ NSURL *url = [NSURL otr_shareLink:baseURL.absoluteString username:self.username fingerprints:fingerprints];
dispatch_async(dispatch_get_main_queue(), ^{
completionBlock(url, nil);
@@ -29,9 +29,7 @@ - (void)setUp {
[super setUp];
self.queue = dispatch_queue_create("OTRMediaTestsQUEUE", 0);
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentsPath = [paths firstObject];
- NSString *filePath = [documentsPath stringByAppendingPathComponent:@"test.sqlite"];
+ NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:NSStringFromSelector(_cmd)];
if([[NSFileManager defaultManager] fileExistsAtPath:filePath isDirectory:nil]) {
[[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
@@ -8,8 +8,10 @@
#import <XCTest/XCTest.h>
#import <ChatSecureCore/NSURL+ChatSecure.h>
+#import <ChatSecureCore/OTRAccount.h>
#import <OTRAssets/OTRBranding.h>
+
@interface OTRURLTests : XCTestCase
@end
@@ -27,18 +29,16 @@ - (void)tearDown {
}
/** Test creating share links and being able to decode sharing links base on https://dev.guardianproject.info/projects/gibberbot/wiki/Invite_Links*/
-/*
- (void)testCreatingURL {
NSString *username = @"account@server.com";
- NSString *baseUrl = [OTRBranding shareBaseURL].absoluteString;
+ NSString *baseUrl = @"https://chatsecure.org/i/#";
NSString *fingerprint = @"fingerprint";
+ NSString *typeString = [OTRAccount fingerprintStringTypeForFingerprintType:OTRFingerprintTypeOTR];
+ NSDictionary <NSString*,NSString*>*fingerprintDictionary = @{typeString:fingerprint};
- [NSURL otr_shareLink:baseUrl username:username fingerprints:@[fingerprint] base64Encoded:NO];
- NSURL *url = [NSURL otr_shareLink:baseUrl username:username fingerprint:fingerprint base64Encoded:NO];
- NSURL *urlWithOutFingerprint = [NSURL otr_shareLink:baseUrl username:username fingerprint:nil base64Encoded:NO];
- NSURL *base64URL = [NSURL otr_shareLink:baseUrl username:username fingerprint:fingerprint base64Encoded:YES];
- NSURL *base64URLWithoutFingerprint = [NSURL otr_shareLink:baseUrl username:username fingerprint:nil base64Encoded:YES];
+ NSURL *base64URL = [NSURL otr_shareLink:baseUrl username:username fingerprints:fingerprintDictionary];
+ NSURL *base64URLWithoutFingerprint = [NSURL otr_shareLink:baseUrl username:username fingerprints:nil];
void (^block)(NSString *, NSString *) = ^void(NSString *uName, NSString *fPrint) {
BOOL equalUsername = [username isEqualToString:uName];
@@ -54,9 +54,6 @@ - (void)testCreatingURL {
[base64URL otr_decodeShareLink:block];
[base64URLWithoutFingerprint otr_decodeShareLink:withoutFingerprintblock];
- [url otr_decodeShareLink:block];
- [urlWithOutFingerprint otr_decodeShareLink:withoutFingerprintblock];
}
- */
@end
@@ -14,7 +14,19 @@ import ChatSecure_Push_iOS
class PushSerializerTest: XCTestCase {
func testSerialization() {
- let array = [Token(tokenString: "token1", type: .iOS, deviceID: nil),Token(tokenString: "token2", type: .iOS, deviceID: nil),Token(tokenString: "token3", type: .iOS, deviceID: nil)]
+
+ let date = NSDate(timeIntervalSinceNow: 100)
+
+ var array = [
+ Token(tokenString: "token1", type: .iOS, deviceID: "deviceid"),
+ Token(tokenString: "token2", type: .iOS, deviceID: "deviceid"),
+ Token(tokenString: "token3", type: .iOS, deviceID: "deviceid")
+ ]
+ array = array.map { (token) -> Token in
+ token.expires = date
+ return token
+ }
+
let data = try! PushSerializer.serialize(array, APIEndpoint: "https://example.com/messages")
XCTAssertNotNil(data,"No json data")
do {
@@ -23,9 +35,5 @@ class PushSerializerTest: XCTestCase {
} catch let error as NSError {
XCTAssertNil(error)
}
-
-
-
-
}
}
View
@@ -145,11 +145,13 @@ PODS:
- XMPPFramework/XEP-0280
- XMPPFramework/XEP-0297
- XMPPFramework/XEP-0308
+ - XMPPFramework/XEP-0313
- XMPPFramework/XEP-0333
- XMPPFramework/XEP-0334
- XMPPFramework/XEP-0335
- XMPPFramework/XEP-0352
- XMPPFramework/XEP-0357
+ - XMPPFramework/XEP-0363
- XMPPFramework/BandwidthMonitor (3.6.7):
- XMPPFramework/Core
- XMPPFramework/Core (3.6.7):
@@ -242,6 +244,9 @@ PODS:
- XMPPFramework/XEP-0203
- XMPPFramework/XEP-0308 (3.6.7):
- XMPPFramework/Core
+ - XMPPFramework/XEP-0313 (3.6.7):
+ - XMPPFramework/Core
+ - XMPPFramework/XEP-0059
- XMPPFramework/XEP-0333 (3.6.7):
- XMPPFramework/Core
- XMPPFramework/XEP-0334 (3.6.7):
@@ -252,6 +257,8 @@ PODS:
- XMPPFramework/Core
- XMPPFramework/XEP-0357 (3.6.7):
- XMPPFramework/Core
+ - XMPPFramework/XEP-0363 (3.6.7):
+ - XMPPFramework/Core
- YapDatabase/SQLCipher (2.9):
- YapDatabase/SQLCipher/Core (= 2.9)
- YapDatabase/SQLCipher/Extensions (= 2.9)
@@ -411,7 +418,7 @@ SPEC CHECKSUMS:
uservoice-iphone-sdk: 9abf27254c8488d7b72d70fb9b621132d6beebd4
VTAcknowledgementsViewController: 6056f5f5e5ed995bbf0581bed6ddd29355ca9a80
XLForm: c9ee7e0f859341279bfd894f9589a9d25c23e4df
- XMPPFramework: 46b686510e4b6ebed5048b906a08934bd8a83aad
+ XMPPFramework: 19145ffbbaae9b6e2da85eddc9c299b39fd56505
YapDatabase: c00f4197bba2fea17bdbd82c8e8e3f7104b6fa67
ZXingObjC: bf15b3814f7a105b6d99f47da2333c93a063650a

0 comments on commit 191cf23

Please sign in to comment.