From 2addb9e81d22ebe2c2a42eb9f3ccb9e0aa180a76 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Sat, 3 Jun 2017 17:38:32 -0700 Subject: [PATCH 01/12] Fixed test build. Some tests still failing. Executed 85 tests, with 22 failures (17 unexpected) in 7.416 (8.531) seconds // FREEBIE --- .gitignore | 1 + .../TSKitiOSTestApp.xcodeproj/project.pbxproj | 12 ++++- tests/Contacts/SignalRecipientTest.m | 5 +- tests/Contacts/TSThreadTest.m | 8 +-- tests/Messages/Interactions/TSMessageTest.m | 12 +++-- .../Interactions/TSOutgoingMessageTest.m | 22 +++----- .../Messages/OWSDisappearingMessagesJobTest.m | 25 ++++------ tests/Messages/OWSMessageSenderTest.m | 28 ++++------- tests/Storage/OWSOrphanedDataCleanerTest.m | 6 +-- .../Storage/TSStorageIdentityKeyStoreTests.m | 50 +++++-------------- .../Fakes/OWSFakeContactsUpdater.m | 4 +- .../TestSupport/Fakes/OWSFakeMessageSender.h | 1 + tests/TestSupport/Fakes/OWSFakePreferences.h | 14 ++++++ tests/TestSupport/Fakes/OWSFakePreferences.m | 14 ++++++ .../Fakes/OWSUnitTestEnvironment.m | 4 +- 15 files changed, 100 insertions(+), 106 deletions(-) create mode 100644 tests/TestSupport/Fakes/OWSFakePreferences.h create mode 100644 tests/TestSupport/Fakes/OWSFakePreferences.m diff --git a/.gitignore b/.gitignore index 649f2f60c..fe9a179d5 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ DerivedData *.hmap *.ipa *.xcuserstate +xcshareddata Pods/ diff --git a/Example/TSKitiOSTestApp/TSKitiOSTestApp.xcodeproj/project.pbxproj b/Example/TSKitiOSTestApp/TSKitiOSTestApp.xcodeproj/project.pbxproj index df61b880c..e210e6c70 100644 --- a/Example/TSKitiOSTestApp/TSKitiOSTestApp.xcodeproj/project.pbxproj +++ b/Example/TSKitiOSTestApp/TSKitiOSTestApp.xcodeproj/project.pbxproj @@ -35,6 +35,8 @@ 45AE484F1E072906004D96C2 /* OWSFakeNotificationsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 45AE484E1E072906004D96C2 /* OWSFakeNotificationsManager.m */; }; 45B700971D9841E400269FFD /* OWSDisappearingMessagesConfigurationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45B700961D9841E400269FFD /* OWSDisappearingMessagesConfigurationTest.m */; }; 45B840211D988DA100F9E938 /* OWSReadReceiptTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45B840201D988DA100F9E938 /* OWSReadReceiptTest.m */; }; + 45C5F5A51EE38AB400E1D20D /* OWSFakePreferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 45C5F5A41EE38AB400E1D20D /* OWSFakePreferences.m */; }; + 45C5F5A61EE38AB400E1D20D /* OWSFakePreferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 45C5F5A41EE38AB400E1D20D /* OWSFakePreferences.m */; }; 45C6A09A1D2F029B007D8AC0 /* TSMessageTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45C6A0991D2F029B007D8AC0 /* TSMessageTest.m */; }; 45D7243F1D67899F00E0CA54 /* OWSDeviceProvisionerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45D7243E1D67899F00E0CA54 /* OWSDeviceProvisionerTest.m */; }; 45E741B61E5D14E800735842 /* OWSIncomingMessageFinderTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45E741B51E5D14E800735842 /* OWSIncomingMessageFinderTest.m */; }; @@ -100,6 +102,8 @@ 45AE484E1E072906004D96C2 /* OWSFakeNotificationsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSFakeNotificationsManager.m; path = ../../../tests/TestSupport/Fakes/OWSFakeNotificationsManager.m; sourceTree = ""; }; 45B700961D9841E400269FFD /* OWSDisappearingMessagesConfigurationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSDisappearingMessagesConfigurationTest.m; path = ../../../tests/Contacts/OWSDisappearingMessagesConfigurationTest.m; sourceTree = ""; }; 45B840201D988DA100F9E938 /* OWSReadReceiptTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSReadReceiptTest.m; path = ../../../tests/Devices/OWSReadReceiptTest.m; sourceTree = ""; }; + 45C5F5A31EE38AB400E1D20D /* OWSFakePreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWSFakePreferences.h; path = ../../../tests/TestSupport/Fakes/OWSFakePreferences.h; sourceTree = ""; }; + 45C5F5A41EE38AB400E1D20D /* OWSFakePreferences.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSFakePreferences.m; path = ../../../tests/TestSupport/Fakes/OWSFakePreferences.m; sourceTree = ""; }; 45C6A0991D2F029B007D8AC0 /* TSMessageTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TSMessageTest.m; path = ../../../tests/Messages/Interactions/TSMessageTest.m; sourceTree = ""; }; 45D7243E1D67899F00E0CA54 /* OWSDeviceProvisionerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSDeviceProvisionerTest.m; path = ../../../tests/Devices/OWSDeviceProvisionerTest.m; sourceTree = ""; }; 45E741B51E5D14E800735842 /* OWSIncomingMessageFinderTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSIncomingMessageFinderTest.m; path = ../../../tests/Messages/OWSIncomingMessageFinderTest.m; sourceTree = ""; }; @@ -169,6 +173,8 @@ 45AE484E1E072906004D96C2 /* OWSFakeNotificationsManager.m */, 452137211E8D6D2F0048FD10 /* OWSFakeMessageSender.h */, 452137221E8D6D2F0048FD10 /* OWSFakeMessageSender.m */, + 45C5F5A31EE38AB400E1D20D /* OWSFakePreferences.h */, + 45C5F5A41EE38AB400E1D20D /* OWSFakePreferences.m */, ); name = Fakes; sourceTree = ""; @@ -457,7 +463,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; 276B029791E679B0E87877B7 /* [CP] Copy Pods Resources */ = { @@ -532,7 +538,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -543,6 +549,7 @@ buildActionMask = 2147483647; files = ( B6273DDC1C13A2E500738558 /* ViewController.m in Sources */, + 45C5F5A51EE38AB400E1D20D /* OWSFakePreferences.m in Sources */, B6273DD91C13A2E500738558 /* AppDelegate.m in Sources */, B6273DD61C13A2E500738558 /* main.m in Sources */, ); @@ -572,6 +579,7 @@ 45458B7A1CC342B600A02153 /* TSStorageSignedPreKeyStore.m in Sources */, 453E1FDB1DA83EFB00DDD7B7 /* OWSFakeContactsUpdater.m in Sources */, 452137231E8D6D2F0048FD10 /* OWSFakeMessageSender.m in Sources */, + 45C5F5A61EE38AB400E1D20D /* OWSFakePreferences.m in Sources */, D2AECE731DE8C3360068CE15 /* ContactSortingTest.m in Sources */, 453E1FD81DA83E1000DDD7B7 /* OWSFakeContactsManager.m in Sources */, 454021ED1D960ABF00F2126D /* OWSDisappearingMessageFinderTest.m in Sources */, diff --git a/tests/Contacts/SignalRecipientTest.m b/tests/Contacts/SignalRecipientTest.m index 436d92555..b5fd06045 100644 --- a/tests/Contacts/SignalRecipientTest.m +++ b/tests/Contacts/SignalRecipientTest.m @@ -26,10 +26,7 @@ { // Sanity Check XCTAssertNotNil(self.localNumber); - [[[SignalRecipient alloc] initWithTextSecureIdentifier:self.localNumber - relay:nil - supportsVoice:YES - supportsWebRTC:YES] save]; + [[[SignalRecipient alloc] initWithTextSecureIdentifier:self.localNumber relay:nil] save]; XCTAssertNotNil([SignalRecipient recipientWithTextSecureIdentifier:self.localNumber]); SignalRecipient *me = [SignalRecipient selfRecipient]; diff --git a/tests/Contacts/TSThreadTest.m b/tests/Contacts/TSThreadTest.m index 4f21d770d..d0fc59240 100644 --- a/tests/Contacts/TSThreadTest.m +++ b/tests/Contacts/TSThreadTest.m @@ -66,7 +66,8 @@ XCTAssertEqual(0, [thread numberOfInteractions]); NSError *error; - TSAttachmentStream *incomingAttachment = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg"]; + TSAttachmentStream *incomingAttachment = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg" + sourceFilename:nil]; [incomingAttachment writeData:[NSData new] error:&error]; [incomingAttachment save]; @@ -83,7 +84,8 @@ expiresInSeconds:0]; [incomingMessage save]; - TSAttachmentStream *outgoingAttachment = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg"]; + TSAttachmentStream *outgoingAttachment = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg" + sourceFilename:nil]; [outgoingAttachment writeData:[NSData new] error:&error]; [outgoingAttachment save]; @@ -94,7 +96,7 @@ TSOutgoingMessage *outgoingMessage = [[TSOutgoingMessage alloc] initWithTimestamp:10000 inThread:thread messageBody:@"outgoing message body" - attachmentIds:@[ outgoingAttachment.uniqueId ]]; + attachmentIds:[@[ outgoingAttachment.uniqueId ] mutableCopy]]; [outgoingMessage save]; // Sanity check diff --git a/tests/Messages/Interactions/TSMessageTest.m b/tests/Messages/Interactions/TSMessageTest.m index b50b2927d..93bb337b0 100644 --- a/tests/Messages/Interactions/TSMessageTest.m +++ b/tests/Messages/Interactions/TSMessageTest.m @@ -1,4 +1,6 @@ -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "NSDate+millisecondTimeStamp.h" #import "TSAttachmentStream.h" @@ -75,7 +77,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)testDescriptionWithPhotoAttachmentId { - TSAttachment *attachment = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg"]; + TSAttachment *attachment = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg" sourceFilename:nil]; [attachment save]; TSMessage *message = [[TSMessage alloc] initWithTimestamp:1 @@ -89,7 +91,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)testDescriptionWithVideoAttachmentId { - TSAttachment *attachment = [[TSAttachmentStream alloc] initWithContentType:@"video/mp4"]; + TSAttachment *attachment = [[TSAttachmentStream alloc] initWithContentType:@"video/mp4" sourceFilename:nil]; [attachment save]; TSMessage *message = [[TSMessage alloc] initWithTimestamp:1 @@ -103,7 +105,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)testDescriptionWithAudioAttachmentId { - TSAttachment *attachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/mp3"]; + TSAttachment *attachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/mp3" sourceFilename:nil]; [attachment save]; TSMessage *message = [[TSMessage alloc] initWithTimestamp:1 @@ -116,7 +118,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)testDescriptionWithUnkownAudioContentType { - TSAttachment *attachment = [[TSAttachmentStream alloc] initWithContentType:@"non/sense"]; + TSAttachment *attachment = [[TSAttachmentStream alloc] initWithContentType:@"non/sense" sourceFilename:nil]; [attachment save]; TSMessage *message = [[TSMessage alloc] initWithTimestamp:1 diff --git a/tests/Messages/Interactions/TSOutgoingMessageTest.m b/tests/Messages/Interactions/TSOutgoingMessageTest.m index 8ef856ea6..03c5504f6 100644 --- a/tests/Messages/Interactions/TSOutgoingMessageTest.m +++ b/tests/Messages/Interactions/TSOutgoingMessageTest.m @@ -1,5 +1,6 @@ -// Created by Michael Kirk on 10/7/16. -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "TSContactThread.h" #import "TSOutgoingMessage.h" @@ -34,18 +35,7 @@ NS_ASSUME_NONNULL_BEGIN messageBody:nil attachmentIds:[NSMutableArray new] expiresInSeconds:10]; - message.messageState = TSOutgoingMessageStateSent; - XCTAssert(message.shouldStartExpireTimer); -} - -- (void)testShouldStartExpireTimerWithDeliveredMessage -{ - TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:100 - inThread:self.thread - messageBody:nil - attachmentIds:[NSMutableArray new] - expiresInSeconds:10]; - message.messageState = TSOutgoingMessageStateDelivered; + [message updateWithMessageState:TSOutgoingMessageStateSentToService]; XCTAssert(message.shouldStartExpireTimer); } @@ -56,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN messageBody:nil attachmentIds:[NSMutableArray new] expiresInSeconds:10]; - message.messageState = TSOutgoingMessageStateUnsent; + [message updateWithMessageState:TSOutgoingMessageStateUnsent]; XCTAssertFalse(message.shouldStartExpireTimer); } @@ -67,7 +57,7 @@ NS_ASSUME_NONNULL_BEGIN messageBody:nil attachmentIds:[NSMutableArray new] expiresInSeconds:10]; - message.messageState = TSOutgoingMessageStateAttemptingOut; + [message updateWithMessageState:TSOutgoingMessageStateAttemptingOut]; XCTAssertFalse(message.shouldStartExpireTimer); } diff --git a/tests/Messages/OWSDisappearingMessagesJobTest.m b/tests/Messages/OWSDisappearingMessagesJobTest.m index 3562f8035..5ffb4a0a0 100644 --- a/tests/Messages/OWSDisappearingMessagesJobTest.m +++ b/tests/Messages/OWSDisappearingMessagesJobTest.m @@ -1,5 +1,6 @@ -// Created by Michael Kirk on 9/23/16. -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "NSDate+millisecondTimeStamp.h" #import "OWSDisappearingMessagesConfiguration.h" @@ -61,12 +62,12 @@ NS_ASSUME_NONNULL_BEGIN expireStartedAt:0]; [unExpiringMessage save]; - OWSDisappearingMessagesJob *job = - [[OWSDisappearingMessagesJob alloc] initWithStorageManager:[TSStorageManager sharedManager]]; + + OWSDisappearingMessagesJob *job = [OWSDisappearingMessagesJob sharedJob]; // Sanity Check. XCTAssertEqual(4, [TSMessage numberOfKeysInCollection]); - [job run]; + [job startIfNecessary]; XCTAssertEqual(2, [TSMessage numberOfKeysInCollection]); } @@ -75,9 +76,8 @@ NS_ASSUME_NONNULL_BEGIN TSThread *thread = [[TSThread alloc] initWithUniqueId:@"fake-thread-id"]; [thread save]; - OWSDisappearingMessagesJob *job = - [[OWSDisappearingMessagesJob alloc] initWithStorageManager:[TSStorageManager sharedManager]]; - + OWSDisappearingMessagesJob *job = [OWSDisappearingMessagesJob sharedJob]; + OWSDisappearingMessagesConfiguration *configuration = [OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId]; [configuration remove]; @@ -90,8 +90,7 @@ NS_ASSUME_NONNULL_BEGIN expireStartedAt:0]; [expiringMessage save]; - - [job becomeConsistentWithConfigurationForMessage:expiringMessage contactsManager:[OWSFakeContactsManager new]]; + [OWSDisappearingMessagesJob becomeConsistentWithConfigurationForMessage:expiringMessage contactsManager:[OWSFakeContactsManager new]]; configuration = [OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId]; XCTAssertNotNil(configuration); @@ -104,14 +103,10 @@ NS_ASSUME_NONNULL_BEGIN TSThread *thread = [[TSThread alloc] initWithUniqueId:@"fake-thread-id"]; [thread save]; - OWSDisappearingMessagesJob *job = - [[OWSDisappearingMessagesJob alloc] initWithStorageManager:[TSStorageManager sharedManager]]; - OWSDisappearingMessagesConfiguration *configuration = [OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId]; [configuration remove]; - TSMessage *unExpiringMessage = [[TSMessage alloc] initWithTimestamp:1 inThread:thread messageBody:@"unexpiringMessage" @@ -119,7 +114,7 @@ NS_ASSUME_NONNULL_BEGIN expiresInSeconds:0 expireStartedAt:0]; [unExpiringMessage save]; - [job becomeConsistentWithConfigurationForMessage:unExpiringMessage contactsManager:[OWSFakeContactsManager new]]; + [OWSDisappearingMessagesJob becomeConsistentWithConfigurationForMessage:unExpiringMessage contactsManager:[OWSFakeContactsManager new]]; XCTAssertNil([OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId]); } diff --git a/tests/Messages/OWSMessageSenderTest.m b/tests/Messages/OWSMessageSenderTest.m index 820f21d14..4cdfcb7c0 100644 --- a/tests/Messages/OWSMessageSenderTest.m +++ b/tests/Messages/OWSMessageSenderTest.m @@ -130,7 +130,7 @@ NS_ASSUME_NONNULL_BEGIN @interface OWSMessageSenderFakeNetworkManager : OWSFakeNetworkManager -- (instancetype)init NS_UNAVAILABLE; +- (instancetype)init; - (instancetype)initWithSuccess:(BOOL)shouldSucceed NS_DESIGNATED_INITIALIZER; @property (nonatomic, readonly) BOOL shouldSucceed; @@ -141,7 +141,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithSuccess:(BOOL)shouldSucceed { - self = [super init]; + self = [self init]; if (!self) { return self; } @@ -316,7 +316,7 @@ NS_ASSUME_NONNULL_BEGIN XCTestExpectation *markedAsSent = [self expectationWithDescription:@"markedAsSent"]; [messageSender sendMessage:message success:^() { - if (message.messageState == TSOutgoingMessageStateSent) { + if (message.messageState == TSOutgoingMessageStateSentToService) { [markedAsSent fulfill]; } else { XCTFail(@"Unexpected message state"); @@ -341,9 +341,10 @@ NS_ASSUME_NONNULL_BEGIN XCTestExpectation *markedAsSent = [self expectationWithDescription:@"markedAsSent"]; [messageSender sendAttachmentData:[NSData new] contentType:@"image/gif" + sourceFilename:nil inMessage:message success:^() { - if (message.messageState == TSOutgoingMessageStateSent) { + if (message.messageState == TSOutgoingMessageStateSentToService) { [markedAsSent fulfill]; } else { XCTFail(@"Unexpected message state"); @@ -394,6 +395,7 @@ NS_ASSUME_NONNULL_BEGIN XCTestExpectation *markedAsUnsent = [self expectationWithDescription:@"markedAsUnsent"]; [messageSender sendAttachmentData:[NSData new] contentType:@"image/gif" + sourceFilename:nil inMessage:message success:^{ XCTFail(@"sendMessage should fail."); @@ -422,6 +424,7 @@ NS_ASSUME_NONNULL_BEGIN XCTestExpectation *markedAsUnsent = [self expectationWithDescription:@"markedAsUnsent"]; [messageSender sendAttachmentData:[NSData new] contentType:@"image/gif" + sourceFilename:nil inMessage:message success:^{ XCTFail(@"sendMessage should fail."); @@ -444,15 +447,9 @@ NS_ASSUME_NONNULL_BEGIN NSData *groupIdData = [Cryptography generateRandomBytes:32]; SignalRecipient *successfulRecipient = - [[SignalRecipient alloc] initWithTextSecureIdentifier:@"successful-recipient-id" - relay:nil - supportsVoice:YES - supportsWebRTC:YES]; + [[SignalRecipient alloc] initWithTextSecureIdentifier:@"successful-recipient-id" relay:nil]; SignalRecipient *successfulRecipient2 = - [[SignalRecipient alloc] initWithTextSecureIdentifier:@"successful-recipient-id2" - relay:nil - supportsVoice:YES - supportsWebRTC:YES]; + [[SignalRecipient alloc] initWithTextSecureIdentifier:@"successful-recipient-id2" relay:nil]; TSGroupModel *groupModel = [[TSGroupModel alloc] initWithTitle:@"group title" @@ -467,7 +464,7 @@ NS_ASSUME_NONNULL_BEGIN XCTestExpectation *markedAsSent = [self expectationWithDescription:@"markedAsSent"]; [messageSender sendMessage:message success:^{ - if (message.messageState == TSOutgoingMessageStateSent) { + if (message.messageState == TSOutgoingMessageStateSentToService) { [markedAsSent fulfill]; } else { XCTFail(@"Unexpected message state"); @@ -483,10 +480,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)testGetRecipients { - SignalRecipient *recipient = [[SignalRecipient alloc] initWithTextSecureIdentifier:@"fake-recipient-id" - relay:nil - supportsVoice:YES - supportsWebRTC:YES]; + SignalRecipient *recipient = [[SignalRecipient alloc] initWithTextSecureIdentifier:@"fake-recipient-id" relay:nil]; [recipient save]; OWSMessageSender *messageSender = self.successfulMessageSender; diff --git a/tests/Storage/OWSOrphanedDataCleanerTest.m b/tests/Storage/OWSOrphanedDataCleanerTest.m index 432d9e1ea..83eef18d7 100644 --- a/tests/Storage/OWSOrphanedDataCleanerTest.m +++ b/tests/Storage/OWSOrphanedDataCleanerTest.m @@ -77,7 +77,7 @@ - (void)testFilesWithoutInteractionsAreDeleted { NSError *error; - TSAttachmentStream *attachmentStream = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg"]; + TSAttachmentStream *attachmentStream = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg" sourceFilename:nil]; [attachmentStream writeData:[NSData new] error:&error]; [attachmentStream save]; NSString *orphanedFilePath = [attachmentStream filePath]; @@ -97,7 +97,7 @@ [savedThread save]; NSError *error; - TSAttachmentStream *attachmentStream = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg"]; + TSAttachmentStream *attachmentStream = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg" sourceFilename:nil]; [attachmentStream writeData:[NSData new] error:&error]; [attachmentStream save]; @@ -125,7 +125,7 @@ - (void)testFilesWithoutAttachmentStreamsAreDeleted { NSError *error; - TSAttachmentStream *attachmentStream = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg"]; + TSAttachmentStream *attachmentStream = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg" sourceFilename:nil]; [attachmentStream writeData:[NSData new] error:&error]; // Intentionally not saved, because we want a lingering file. diff --git a/tests/Storage/TSStorageIdentityKeyStoreTests.m b/tests/Storage/TSStorageIdentityKeyStoreTests.m index fffa357b0..fa34a554f 100644 --- a/tests/Storage/TSStorageIdentityKeyStoreTests.m +++ b/tests/Storage/TSStorageIdentityKeyStoreTests.m @@ -1,9 +1,5 @@ // -// TSStorageIdentityKeyStoreTests.m -// TextSecureKit -// -// Created by Frederic Jacobs on 06/11/14. -// Copyright (c) 2014 Open Whisper Systems. All rights reserved. +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // #import @@ -11,7 +7,6 @@ #import "OWSUnitTestEnvironment.h" #import "SecurityUtils.h" -#import "TSPrivacyPreferences.h" #import "TSStorageManager+IdentityKeyStore.h" #import "TSStorageManager.h" #import "TextSecureKitEnv.h" @@ -37,7 +32,8 @@ NSData *newKey = [SecurityUtils generateRandomBytes:32]; NSString *recipientId = @"test@gmail.com"; - XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId]); + XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId direction:TSMessageDirectionOutgoing]); + XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId direction:TSMessageDirectionIncoming]); } - (void)testAlreadyRegisteredKey { @@ -46,48 +42,28 @@ [[TSStorageManager sharedManager] saveRemoteIdentity:newKey recipientId:recipientId]; - XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId]); + XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId direction:TSMessageDirectionOutgoing]); + XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId direction:TSMessageDirectionIncoming]); } -- (void)testChangedKeyWithBlockingIdentityChanges +- (void)testChangedKey { - TSPrivacyPreferences *preferences = [TSPrivacyPreferences sharedInstance]; - preferences.shouldBlockOnIdentityChange = YES; - [preferences save]; + NSData *originalKey = [SecurityUtils generateRandomBytes:32]; + NSString *recipientId = @"test@protonmail.com"; - NSData *newKey = [SecurityUtils generateRandomBytes:32]; - NSString *recipientId = @"test@gmail.com"; - - [[TSStorageManager sharedManager] saveRemoteIdentity:newKey recipientId:recipientId]; + [[TSStorageManager sharedManager] saveRemoteIdentity:originalKey recipientId:recipientId]; - XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId]); + XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:originalKey recipientId:recipientId direction:TSMessageDirectionOutgoing]); + XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:originalKey recipientId:recipientId direction:TSMessageDirectionIncoming]); NSData *otherKey = [SecurityUtils generateRandomBytes:32]; - XCTAssertFalse([[TSStorageManager sharedManager] isTrustedIdentityKey:otherKey recipientId:recipientId]); + XCTAssertFalse([[TSStorageManager sharedManager] isTrustedIdentityKey:otherKey recipientId:recipientId direction:TSMessageDirectionOutgoing]); + XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:otherKey recipientId:recipientId direction:TSMessageDirectionIncoming]); } -- (void)testChangedKeyWithNonBlockingIdentityChanges -{ - TSPrivacyPreferences *preferences = [TSPrivacyPreferences sharedInstance]; - preferences.shouldBlockOnIdentityChange = NO; - [preferences save]; - - NSData *newKey = [SecurityUtils generateRandomBytes:32]; - NSString *recipientId = @"test@gmail.com"; - - [[TSStorageManager sharedManager] saveRemoteIdentity:newKey recipientId:recipientId]; - - XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId]); - - NSData *otherKey = [SecurityUtils generateRandomBytes:32]; - - [TextSecureKitEnv setSharedEnv:[OWSUnitTestEnvironment new]]; - XCTAssertTrue([[TSStorageManager sharedManager] isTrustedIdentityKey:otherKey recipientId:recipientId]); -} - - (void)testIdentityKey { [[TSStorageManager sharedManager] generateNewIdentityKey]; diff --git a/tests/TestSupport/Fakes/OWSFakeContactsUpdater.m b/tests/TestSupport/Fakes/OWSFakeContactsUpdater.m index 568582fad..46520e554 100644 --- a/tests/TestSupport/Fakes/OWSFakeContactsUpdater.m +++ b/tests/TestSupport/Fakes/OWSFakeContactsUpdater.m @@ -13,9 +13,7 @@ NS_ASSUME_NONNULL_BEGIN { NSLog(@"[OWSFakeContactsUpdater] Faking contact lookup."); return [[SignalRecipient alloc] initWithTextSecureIdentifier:@"fake-recipient-id" - relay:nil - supportsVoice:YES - supportsWebRTC:YES]; + relay:nil]; } @end diff --git a/tests/TestSupport/Fakes/OWSFakeMessageSender.h b/tests/TestSupport/Fakes/OWSFakeMessageSender.h index 2b7c6303e..c8dfc0d0d 100644 --- a/tests/TestSupport/Fakes/OWSFakeMessageSender.h +++ b/tests/TestSupport/Fakes/OWSFakeMessageSender.h @@ -9,6 +9,7 @@ NS_ASSUME_NONNULL_BEGIN @interface OWSFakeMessageSender : OWSMessageSender +- (instancetype)init; - (instancetype)initWithExpectation:(XCTestExpectation *)expectation; @property (nonatomic, readonly) XCTestExpectation *expectation; diff --git a/tests/TestSupport/Fakes/OWSFakePreferences.h b/tests/TestSupport/Fakes/OWSFakePreferences.h new file mode 100644 index 000000000..51b04bbfa --- /dev/null +++ b/tests/TestSupport/Fakes/OWSFakePreferences.h @@ -0,0 +1,14 @@ +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// + +#import +#import "TSPreferences.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OWSFakePreferences : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/tests/TestSupport/Fakes/OWSFakePreferences.m b/tests/TestSupport/Fakes/OWSFakePreferences.m new file mode 100644 index 000000000..51a120e34 --- /dev/null +++ b/tests/TestSupport/Fakes/OWSFakePreferences.m @@ -0,0 +1,14 @@ +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// + +#import "OWSFakePreferences.h" + +@implementation OWSFakePreferences + +- (BOOL)isSendingIdentityApprovalRequired +{ + return NO; +} + +@end diff --git a/tests/TestSupport/Fakes/OWSUnitTestEnvironment.m b/tests/TestSupport/Fakes/OWSUnitTestEnvironment.m index a4d09fad1..89cab4a36 100644 --- a/tests/TestSupport/Fakes/OWSUnitTestEnvironment.m +++ b/tests/TestSupport/Fakes/OWSUnitTestEnvironment.m @@ -7,6 +7,7 @@ #import "OWSFakeContactsManager.h" #import "OWSFakeMessageSender.h" #import "OWSFakeNotificationsManager.h" +#import "OWSFakePreferences.h" NS_ASSUME_NONNULL_BEGIN @@ -17,7 +18,8 @@ NS_ASSUME_NONNULL_BEGIN return [super initWithCallMessageHandler:[OWSFakeCallMessageHandler new] contactsManager:[OWSFakeContactsManager new] messageSender:[OWSFakeMessageSender new] - notificationsManager:[OWSFakeNotificationsManager new]]; + notificationsManager:[OWSFakeNotificationsManager new] + preferences:[OWSFakePreferences new]]; } @end From 13c5bdb8c5d972ab49a4a0e40d8e0ad56b7e1673 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Sat, 3 Jun 2017 17:54:40 -0700 Subject: [PATCH 02/12] fix disappearing messages test // FREEBIE --- tests/Messages/OWSDisappearingMessagesJobTest.m | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/Messages/OWSDisappearingMessagesJobTest.m b/tests/Messages/OWSDisappearingMessagesJobTest.m index 5ffb4a0a0..1ed0cdf84 100644 --- a/tests/Messages/OWSDisappearingMessagesJobTest.m +++ b/tests/Messages/OWSDisappearingMessagesJobTest.m @@ -14,6 +14,14 @@ NS_ASSUME_NONNULL_BEGIN +@interface OWSDisappearingMessagesJob (Testing) + +- (void)run; +- (void)becomeConsistentWithConfigurationForMessage:(TSMessage *)message + contactsManager:(id)contactsManager; + +@end + @interface OWSDisappearingMessagesJobTest : XCTestCase @end @@ -67,7 +75,7 @@ NS_ASSUME_NONNULL_BEGIN // Sanity Check. XCTAssertEqual(4, [TSMessage numberOfKeysInCollection]); - [job startIfNecessary]; + [job run]; XCTAssertEqual(2, [TSMessage numberOfKeysInCollection]); } @@ -90,7 +98,7 @@ NS_ASSUME_NONNULL_BEGIN expireStartedAt:0]; [expiringMessage save]; - [OWSDisappearingMessagesJob becomeConsistentWithConfigurationForMessage:expiringMessage contactsManager:[OWSFakeContactsManager new]]; + [job becomeConsistentWithConfigurationForMessage:expiringMessage contactsManager:[OWSFakeContactsManager new]]; configuration = [OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId]; XCTAssertNotNil(configuration); From 1fb9fa79dfefccf2322fba1450455db7238e2bee Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Sat, 3 Jun 2017 18:29:41 -0700 Subject: [PATCH 03/12] Fix up some more tests. // FREEBIE --- tests/Contacts/TSContactThreadTest.m | 7 +++++-- tests/Messages/Interactions/TSMessageTest.m | 16 ++++++++++++++-- tests/Messages/OWSMessageSenderTest.m | 5 ++++- tests/Messages/TSMessagesManagerTest.m | 8 ++++++++ tests/Storage/TSStorageIdentityKeyStoreTests.m | 4 +++- tests/TestSupport/Fakes/OWSFakeContactsManager.m | 12 +++++++++--- .../Fakes/OWSFakeNotificationsManager.m | 7 ++++--- tests/TestSupport/Fakes/OWSUnitTestEnvironment.h | 6 ++++-- tests/TestSupport/Fakes/OWSUnitTestEnvironment.m | 10 +++++++++- 9 files changed, 60 insertions(+), 15 deletions(-) diff --git a/tests/Contacts/TSContactThreadTest.m b/tests/Contacts/TSContactThreadTest.m index 6498cd4d2..4194f06cb 100644 --- a/tests/Contacts/TSContactThreadTest.m +++ b/tests/Contacts/TSContactThreadTest.m @@ -1,8 +1,10 @@ -// Created by Michael Kirk on 11/7/16. -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "TSContactThread.h" #import "TSStorageManager+identityKeyStore.h" +#import "OWSUnitTestEnvironment.h" #import NS_ASSUME_NONNULL_BEGIN @@ -17,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)setUp { + [OWSUnitTestEnvironment ensureSetup]; self.contactThread = [TSContactThread getOrCreateThreadWithContactId:@"fake-contact-id"]; [self.contactThread.storageManager removeIdentityKeyForRecipient:self.contactThread.contactIdentifier]; } diff --git a/tests/Messages/Interactions/TSMessageTest.m b/tests/Messages/Interactions/TSMessageTest.m index 93bb337b0..e956d485b 100644 --- a/tests/Messages/Interactions/TSMessageTest.m +++ b/tests/Messages/Interactions/TSMessageTest.m @@ -102,10 +102,9 @@ NS_ASSUME_NONNULL_BEGIN XCTAssertEqualObjects(@"📽 ATTACHMENT", actualDescription); } - - (void)testDescriptionWithAudioAttachmentId { - TSAttachment *attachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/mp3" sourceFilename:nil]; + TSAttachment *attachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/mp3" sourceFilename:@"some-file.mp3"]; [attachment save]; TSMessage *message = [[TSMessage alloc] initWithTimestamp:1 @@ -116,6 +115,19 @@ NS_ASSUME_NONNULL_BEGIN XCTAssertEqualObjects(@"📻 ATTACHMENT", actualDescription); } +- (void)testDescriptionWithVoiceMessageAttachmentId +{ + TSAttachment *attachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/mp3" sourceFilename:nil]; + [attachment save]; + + TSMessage *message = [[TSMessage alloc] initWithTimestamp:1 + inThread:self.thread + messageBody:@"My message body" + attachmentIds:@[ attachment.uniqueId ]]; + NSString *actualDescription = [message description]; + XCTAssertEqualObjects(@"🎤 ATTACHMENT_TYPE_VOICE_MESSAGE", actualDescription); +} + - (void)testDescriptionWithUnkownAudioContentType { TSAttachment *attachment = [[TSAttachmentStream alloc] initWithContentType:@"non/sense" sourceFilename:nil]; diff --git a/tests/Messages/OWSMessageSenderTest.m b/tests/Messages/OWSMessageSenderTest.m index 4cdfcb7c0..e61bed24b 100644 --- a/tests/Messages/OWSMessageSenderTest.m +++ b/tests/Messages/OWSMessageSenderTest.m @@ -94,7 +94,10 @@ NS_ASSUME_NONNULL_BEGIN if (self.shouldSucceed) { successHandler(); } else { - failureHandler(OWSErrorMakeFailedToSendOutgoingMessageError()); + NSError *error = OWSErrorMakeFailedToSendOutgoingMessageError(); + [error setIsRetryable:NO]; + + failureHandler(error); } } diff --git a/tests/Messages/TSMessagesManagerTest.m b/tests/Messages/TSMessagesManagerTest.m index 839aad77d..6fbc01a04 100644 --- a/tests/Messages/TSMessagesManagerTest.m +++ b/tests/Messages/TSMessagesManagerTest.m @@ -18,6 +18,7 @@ #import "TSMessagesManager.h" #import "TSNetworkManager.h" #import "TSStorageManager.h" +#import "OWSUnitTestEnvironment.h" NS_ASSUME_NONNULL_BEGIN @@ -57,6 +58,13 @@ NS_ASSUME_NONNULL_BEGIN messageSender:messageSender]; } +- (void)setUp +{ + [super setUp]; + + [OWSUnitTestEnvironment ensureSetup]; +} + - (void)testIncomingSyncContactMessage { XCTestExpectation *messageWasSent = [self expectationWithDescription:@"message was sent"]; diff --git a/tests/Storage/TSStorageIdentityKeyStoreTests.m b/tests/Storage/TSStorageIdentityKeyStoreTests.m index fa34a554f..41b2fdd5d 100644 --- a/tests/Storage/TSStorageIdentityKeyStoreTests.m +++ b/tests/Storage/TSStorageIdentityKeyStoreTests.m @@ -8,6 +8,7 @@ #import "OWSUnitTestEnvironment.h" #import "SecurityUtils.h" #import "TSStorageManager+IdentityKeyStore.h" +#import "OWSRecipientIdentity.h" #import "TSStorageManager.h" #import "TextSecureKitEnv.h" @@ -19,8 +20,9 @@ - (void)setUp { [super setUp]; + [[TSStorageManager sharedManager] purgeCollection:@"TSStorageManagerTrustedKeysCollection"]; - // Put setup code here. This method is called before the invocation of each test method in the class. + [OWSRecipientIdentity removeAllObjectsInCollection]; } - (void)tearDown { diff --git a/tests/TestSupport/Fakes/OWSFakeContactsManager.m b/tests/TestSupport/Fakes/OWSFakeContactsManager.m index 5c587672e..d67e275e9 100644 --- a/tests/TestSupport/Fakes/OWSFakeContactsManager.m +++ b/tests/TestSupport/Fakes/OWSFakeContactsManager.m @@ -1,5 +1,6 @@ -// Created by Michael Kirk on 10/7/16. -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "OWSFakeContactsManager.h" @@ -14,7 +15,12 @@ NS_ASSUME_NONNULL_BEGIN return @"Fake name"; } -- (NSArray * _Nonnull)signalContacts +- (NSArray *)signalContacts +{ + return @[]; +} + +- (NSArray *)signalAccounts { return @[]; } diff --git a/tests/TestSupport/Fakes/OWSFakeNotificationsManager.m b/tests/TestSupport/Fakes/OWSFakeNotificationsManager.m index bcc385b70..fd96833c0 100644 --- a/tests/TestSupport/Fakes/OWSFakeNotificationsManager.m +++ b/tests/TestSupport/Fakes/OWSFakeNotificationsManager.m @@ -1,5 +1,6 @@ -// Created by Michael Kirk on 12/18/16. -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "OWSFakeNotificationsManager.h" @@ -8,8 +9,8 @@ NS_ASSUME_NONNULL_BEGIN @implementation OWSFakeNotificationsManager - (void)notifyUserForIncomingMessage:(TSIncomingMessage *)incomingMessage - from:(NSString *)name inThread:(TSThread *)thread + contactsManager:(id)contactsManager { NSLog(@"%s", __PRETTY_FUNCTION__); } diff --git a/tests/TestSupport/Fakes/OWSUnitTestEnvironment.h b/tests/TestSupport/Fakes/OWSUnitTestEnvironment.h index aff4171ca..67b49148a 100644 --- a/tests/TestSupport/Fakes/OWSUnitTestEnvironment.h +++ b/tests/TestSupport/Fakes/OWSUnitTestEnvironment.h @@ -1,5 +1,6 @@ -// Created by Michael Kirk on 12/18/16. -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "TextSecureKitEnv.h" @@ -7,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN @interface OWSUnitTestEnvironment : TextSecureKitEnv ++ (void)ensureSetup; - (instancetype)initDefault; @end diff --git a/tests/TestSupport/Fakes/OWSUnitTestEnvironment.m b/tests/TestSupport/Fakes/OWSUnitTestEnvironment.m index 89cab4a36..d04475749 100644 --- a/tests/TestSupport/Fakes/OWSUnitTestEnvironment.m +++ b/tests/TestSupport/Fakes/OWSUnitTestEnvironment.m @@ -13,7 +13,15 @@ NS_ASSUME_NONNULL_BEGIN @implementation OWSUnitTestEnvironment -- (instancetype)init ++ (void)ensureSetup +{ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + [self setSharedEnv:[[self alloc] initDefault]]; + }); +} + +- (instancetype)initDefault { return [super initWithCallMessageHandler:[OWSFakeCallMessageHandler new] contactsManager:[OWSFakeContactsManager new] From edf5852e823b71f27808a33e3e1e264ea37cd71e Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Sat, 3 Jun 2017 18:30:21 -0700 Subject: [PATCH 04/12] set-expiration dispatches *sync* so we can test it. // FREEBIE --- src/Messages/OWSDisappearingMessagesJob.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Messages/OWSDisappearingMessagesJob.m b/src/Messages/OWSDisappearingMessagesJob.m index b3aece129..c2337c199 100644 --- a/src/Messages/OWSDisappearingMessagesJob.m +++ b/src/Messages/OWSDisappearingMessagesJob.m @@ -136,7 +136,7 @@ NS_ASSUME_NONNULL_BEGIN + (void)setExpirationForMessage:(TSMessage *)message { - dispatch_async(self.serialQueue, ^{ + dispatch_sync(self.serialQueue, ^{ [[self sharedJob] setExpirationForMessage:message]; }); } From e652dff4b4ecd6413cc90f6a282765cd58d568b8 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Sat, 3 Jun 2017 18:40:55 -0700 Subject: [PATCH 05/12] Allow override of singleton enforcement in test app We frequently build multiple instances of "singletons" for the purpose of testing. // FREEBIE --- Example/TSKitiOSTestApp/Podfile | 15 ++++++ Example/TSKitiOSTestApp/Podfile.lock | 75 +++++++++++++--------------- src/Util/Asserts.h | 9 ++++ 3 files changed, 60 insertions(+), 39 deletions(-) diff --git a/Example/TSKitiOSTestApp/Podfile b/Example/TSKitiOSTestApp/Podfile index d8a8ec3ad..34bba266c 100644 --- a/Example/TSKitiOSTestApp/Podfile +++ b/Example/TSKitiOSTestApp/Podfile @@ -11,3 +11,18 @@ target 'TSKitiOSTestApp' do end end +post_install do |installer| + installer.pods_project.targets.each do |target| + if target.to_s == "SignalServiceKit" + puts "--[!] Disabling singleton enforcement for SSK." + target.build_configurations.each do |config| + existing_definitions = config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] + if existing_definitions == nil || existing.length == 0 + existing_definitions = "$(inheritied)" + end + + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = "#{existing_definitions} SSK_NO_ENFORCE_SINGLETONS=1" + end + end + end +end diff --git a/Example/TSKitiOSTestApp/Podfile.lock b/Example/TSKitiOSTestApp/Podfile.lock index c1dbfc0f1..3378b92cf 100644 --- a/Example/TSKitiOSTestApp/Podfile.lock +++ b/Example/TSKitiOSTestApp/Podfile.lock @@ -28,12 +28,11 @@ PODS: - CocoaLumberjack/Extensions (2.4.0): - CocoaLumberjack/Default - HKDFKit (0.0.3) - - libPhoneNumber-iOS (0.9.4) + - libPhoneNumber-iOS (0.9.10) - Mantle (2.1.0): - Mantle/extobjc (= 2.1.0) - Mantle/extobjc (2.1.0) - ProtocolBuffers (1.9.11) - - Reachability (3.2) - SAMKeychain (1.5.2) - SignalServiceKit (0.9.0): - '25519' @@ -45,7 +44,7 @@ PODS: - SAMKeychain - SocketRocket - TwistedOakCollapsingFutures - - YapDatabase/SQLCipher + - YapDatabase/SQLCipher (~> 2.9.3) - SocketRocket (0.5.1) - SQLCipher/common (3.4.1) - SQLCipher/fts (3.4.1): @@ -53,54 +52,53 @@ PODS: - TwistedOakCollapsingFutures (1.0.0): - UnionFind (~> 1.0) - UnionFind (1.0.1) - - YapDatabase/SQLCipher (2.9.2): - - YapDatabase/SQLCipher/Core (= 2.9.2) - - YapDatabase/SQLCipher/Extensions (= 2.9.2) - - YapDatabase/SQLCipher/Core (2.9.2): + - YapDatabase/SQLCipher (2.9.3): + - YapDatabase/SQLCipher/Core (= 2.9.3) + - YapDatabase/SQLCipher/Extensions (= 2.9.3) + - YapDatabase/SQLCipher/Core (2.9.3): - CocoaLumberjack (~> 2) - SQLCipher/fts - - YapDatabase/SQLCipher/Extensions (2.9.2): + - YapDatabase/SQLCipher/Extensions (2.9.3): - YapDatabase/SQLCipher/Core - - YapDatabase/SQLCipher/Extensions/ActionManager (= 2.9.2) - - YapDatabase/SQLCipher/Extensions/CloudKit (= 2.9.2) - - YapDatabase/SQLCipher/Extensions/ConnectionProxy (= 2.9.2) - - YapDatabase/SQLCipher/Extensions/CrossProcessNotification (= 2.9.2) - - YapDatabase/SQLCipher/Extensions/FilteredViews (= 2.9.2) - - YapDatabase/SQLCipher/Extensions/FullTextSearch (= 2.9.2) - - YapDatabase/SQLCipher/Extensions/Hooks (= 2.9.2) - - YapDatabase/SQLCipher/Extensions/Relationships (= 2.9.2) - - YapDatabase/SQLCipher/Extensions/RTreeIndex (= 2.9.2) - - YapDatabase/SQLCipher/Extensions/SearchResults (= 2.9.2) - - YapDatabase/SQLCipher/Extensions/SecondaryIndex (= 2.9.2) - - YapDatabase/SQLCipher/Extensions/Views (= 2.9.2) - - YapDatabase/SQLCipher/Extensions/ActionManager (2.9.2): - - Reachability (~> 3) + - YapDatabase/SQLCipher/Extensions/ActionManager (= 2.9.3) + - YapDatabase/SQLCipher/Extensions/CloudKit (= 2.9.3) + - YapDatabase/SQLCipher/Extensions/ConnectionProxy (= 2.9.3) + - YapDatabase/SQLCipher/Extensions/CrossProcessNotification (= 2.9.3) + - YapDatabase/SQLCipher/Extensions/FilteredViews (= 2.9.3) + - YapDatabase/SQLCipher/Extensions/FullTextSearch (= 2.9.3) + - YapDatabase/SQLCipher/Extensions/Hooks (= 2.9.3) + - YapDatabase/SQLCipher/Extensions/Relationships (= 2.9.3) + - YapDatabase/SQLCipher/Extensions/RTreeIndex (= 2.9.3) + - YapDatabase/SQLCipher/Extensions/SearchResults (= 2.9.3) + - YapDatabase/SQLCipher/Extensions/SecondaryIndex (= 2.9.3) + - YapDatabase/SQLCipher/Extensions/Views (= 2.9.3) + - YapDatabase/SQLCipher/Extensions/ActionManager (2.9.3): - YapDatabase/SQLCipher/Core - YapDatabase/SQLCipher/Extensions/Views - - YapDatabase/SQLCipher/Extensions/CloudKit (2.9.2): + - YapDatabase/SQLCipher/Extensions/CloudKit (2.9.3): - YapDatabase/SQLCipher/Core - - YapDatabase/SQLCipher/Extensions/ConnectionProxy (2.9.2): + - YapDatabase/SQLCipher/Extensions/ConnectionProxy (2.9.3): - YapDatabase/SQLCipher/Core - - YapDatabase/SQLCipher/Extensions/CrossProcessNotification (2.9.2): + - YapDatabase/SQLCipher/Extensions/CrossProcessNotification (2.9.3): - YapDatabase/SQLCipher/Core - - YapDatabase/SQLCipher/Extensions/FilteredViews (2.9.2): + - YapDatabase/SQLCipher/Extensions/FilteredViews (2.9.3): - YapDatabase/SQLCipher/Core - YapDatabase/SQLCipher/Extensions/Views - - YapDatabase/SQLCipher/Extensions/FullTextSearch (2.9.2): + - YapDatabase/SQLCipher/Extensions/FullTextSearch (2.9.3): - YapDatabase/SQLCipher/Core - - YapDatabase/SQLCipher/Extensions/Hooks (2.9.2): + - YapDatabase/SQLCipher/Extensions/Hooks (2.9.3): - YapDatabase/SQLCipher/Core - - YapDatabase/SQLCipher/Extensions/Relationships (2.9.2): + - YapDatabase/SQLCipher/Extensions/Relationships (2.9.3): - YapDatabase/SQLCipher/Core - - YapDatabase/SQLCipher/Extensions/RTreeIndex (2.9.2): + - YapDatabase/SQLCipher/Extensions/RTreeIndex (2.9.3): - YapDatabase/SQLCipher/Core - - YapDatabase/SQLCipher/Extensions/SearchResults (2.9.2): + - YapDatabase/SQLCipher/Extensions/SearchResults (2.9.3): - YapDatabase/SQLCipher/Core - YapDatabase/SQLCipher/Extensions/FullTextSearch - YapDatabase/SQLCipher/Extensions/Views - - YapDatabase/SQLCipher/Extensions/SecondaryIndex (2.9.2): + - YapDatabase/SQLCipher/Extensions/SecondaryIndex (2.9.3): - YapDatabase/SQLCipher/Core - - YapDatabase/SQLCipher/Extensions/Views (2.9.2): + - YapDatabase/SQLCipher/Extensions/Views (2.9.3): - YapDatabase/SQLCipher/Core DEPENDENCIES: @@ -130,18 +128,17 @@ SPEC CHECKSUMS: AxolotlKit: 240c7d761e4b1be9c6de78ebec498aaeedc978f4 CocoaLumberjack: aa9dcab71bdf9eaf2a63bbd9ddc87863efe45457 HKDFKit: c058305d6f64b84f28c50bd7aa89574625bcb62a - libPhoneNumber-iOS: 63bab980d1fc9783d82d955800ac9d7c1d81fde3 + libPhoneNumber-iOS: f721ae4d5854bce60934f9fb9b0b28e8e68913cb Mantle: 2fa750afa478cd625a94230fbf1c13462f29395b ProtocolBuffers: d509225eb2ea43d9582a59e94348fcf86e2abd65 - Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 SAMKeychain: 1865333198217411f35327e8da61b43de79b635b - SignalServiceKit: 59a79a51b89b963ba94db30cc99ed5212da0bb9f + SignalServiceKit: 2ad8d86da055e24ac3ea0354ec1d4b13251af28f SocketRocket: dbb1554b8fc288ef8ef370d6285aeca7361be31e SQLCipher: 43d12c0eb9c57fb438749618fc3ce0065509a559 TwistedOakCollapsingFutures: f359b90f203e9ab13dfb92c9ff41842a7fe1cd0c UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d - YapDatabase: b1e43555a34a5298e23a045be96817a5ef0da58f + YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266 -PODFILE CHECKSUM: 1a7633963dbcaa43f298949d83c42c1cd1dce940 +PODFILE CHECKSUM: 71be258fb0880fd31036771945d15f7c06af4a57 -COCOAPODS: 1.2.0 +COCOAPODS: 1.2.1 diff --git a/src/Util/Asserts.h b/src/Util/Asserts.h index 27d377feb..acd252fbd 100755 --- a/src/Util/Asserts.h +++ b/src/Util/Asserts.h @@ -70,8 +70,17 @@ // // 1. Use OWSSingletonAssertFlag() outside the class definition. // 2. Use OWSSingletonAssertInit() in each initializer. + +#ifndef SSK_NO_ENFORCE_SINGLETONS #ifdef DEBUG +#define ENFORCE_SINGLETONS + +#endif +#endif + +#ifdef ENFORCE_SINGLETONS + #define OWSSingletonAssertFlag() static BOOL _isSingletonCreated = NO; #define OWSSingletonAssertInit() \ From 1b9aae2ea628bb322095e6549be1487546d8d8a0 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 28 Jun 2017 07:32:31 -1000 Subject: [PATCH 06/12] CR: renaming var to be more general // FREEBIE --- Example/TSKitiOSTestApp/Podfile | 2 +- src/Util/Asserts.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/TSKitiOSTestApp/Podfile b/Example/TSKitiOSTestApp/Podfile index 34bba266c..96619ecd8 100644 --- a/Example/TSKitiOSTestApp/Podfile +++ b/Example/TSKitiOSTestApp/Podfile @@ -21,7 +21,7 @@ post_install do |installer| existing_definitions = "$(inheritied)" end - config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = "#{existing_definitions} SSK_NO_ENFORCE_SINGLETONS=1" + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = "#{existing_definitions} SSK_BUILDING_FOR_TESTS=1" end end end diff --git a/src/Util/Asserts.h b/src/Util/Asserts.h index acd252fbd..5c77695bd 100755 --- a/src/Util/Asserts.h +++ b/src/Util/Asserts.h @@ -71,7 +71,7 @@ // 1. Use OWSSingletonAssertFlag() outside the class definition. // 2. Use OWSSingletonAssertInit() in each initializer. -#ifndef SSK_NO_ENFORCE_SINGLETONS +#ifndef SSK_BUILDING_FOR_TESTS #ifdef DEBUG #define ENFORCE_SINGLETONS From 8f9af85cca48d9d0a1a46e0392ea4c6d88c6106f Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 28 Jun 2017 08:09:23 -1000 Subject: [PATCH 07/12] prefer hacks in test to hacks in code. Adding a completion handler would be a bit gnarly since we're snaking through a pretty long method chain. // FREEBIE --- src/Messages/OWSDisappearingMessagesJob.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Messages/OWSDisappearingMessagesJob.m b/src/Messages/OWSDisappearingMessagesJob.m index c2337c199..b3aece129 100644 --- a/src/Messages/OWSDisappearingMessagesJob.m +++ b/src/Messages/OWSDisappearingMessagesJob.m @@ -136,7 +136,7 @@ NS_ASSUME_NONNULL_BEGIN + (void)setExpirationForMessage:(TSMessage *)message { - dispatch_sync(self.serialQueue, ^{ + dispatch_async(self.serialQueue, ^{ [[self sharedJob] setExpirationForMessage:message]; }); } From 1d71ca5e50409d5161460b1e8ff307c389cea896 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 28 Jun 2017 16:18:13 -1000 Subject: [PATCH 08/12] Fix some more tests. Adapt to IdentityManager refactor Adapt to DisappearingMessages refactor // FREEBIE --- Example/TSKitiOSTestApp/Podfile.lock | 7 +-- .../TSKitiOSTestApp.xcodeproj/project.pbxproj | 8 --- tests/Contacts/TSContactThreadTest.m | 8 +-- tests/Contacts/TSThreadTest.m | 2 +- .../OWSDisappearingMessageFinderTest.m | 53 ++++++++++++++----- .../Messages/OWSDisappearingMessagesJobTest.m | 3 ++ tests/Messages/OWSMessageSenderTest.m | 2 + tests/Messages/TSMessagesManagerTest.m | 3 ++ tests/Storage/OWSOrphanedDataCleanerTest.m | 2 +- .../Storage/TSStorageIdentityKeyStoreTests.m | 26 ++++----- tests/TestSupport/Fakes/OWSFakePreferences.h | 14 ----- tests/TestSupport/Fakes/OWSFakePreferences.m | 14 ----- .../Fakes/OWSUnitTestEnvironment.m | 4 +- 13 files changed, 72 insertions(+), 74 deletions(-) delete mode 100644 tests/TestSupport/Fakes/OWSFakePreferences.h delete mode 100644 tests/TestSupport/Fakes/OWSFakePreferences.m diff --git a/Example/TSKitiOSTestApp/Podfile.lock b/Example/TSKitiOSTestApp/Podfile.lock index 3378b92cf..ddf365882 100644 --- a/Example/TSKitiOSTestApp/Podfile.lock +++ b/Example/TSKitiOSTestApp/Podfile.lock @@ -17,6 +17,7 @@ PODS: - AFNetworking/NSURLSession - AxolotlKit (0.8.1): - 25519 (~> 2.0.1) + - CocoaLumberjack - HKDFKit (~> 0.0.3) - ProtocolBuffers (~> 1.9.8) - CocoaLumberjack (2.4.0): @@ -116,7 +117,7 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: AxolotlKit: - :commit: a3c843cc8a423c5924c663490978f81dba34d04e + :commit: 28afe5c1dbcfdea73d147e464c53d191d1e3ea50 :git: https://github.com/WhisperSystems/SignalProtocolKit.git SocketRocket: :commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf @@ -125,7 +126,7 @@ CHECKOUT OPTIONS: SPEC CHECKSUMS: '25519': dc4bad7e2dbcbf1efa121068a705a44cd98c80fc AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 - AxolotlKit: 240c7d761e4b1be9c6de78ebec498aaeedc978f4 + AxolotlKit: a9530d6835baae0f204b1f6b9dd79b7901176f0d CocoaLumberjack: aa9dcab71bdf9eaf2a63bbd9ddc87863efe45457 HKDFKit: c058305d6f64b84f28c50bd7aa89574625bcb62a libPhoneNumber-iOS: f721ae4d5854bce60934f9fb9b0b28e8e68913cb @@ -139,6 +140,6 @@ SPEC CHECKSUMS: UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266 -PODFILE CHECKSUM: 71be258fb0880fd31036771945d15f7c06af4a57 +PODFILE CHECKSUM: 124c05542083fefccb75f4b7afbdd839e27ff5ab COCOAPODS: 1.2.1 diff --git a/Example/TSKitiOSTestApp/TSKitiOSTestApp.xcodeproj/project.pbxproj b/Example/TSKitiOSTestApp/TSKitiOSTestApp.xcodeproj/project.pbxproj index e210e6c70..c6880e3a6 100644 --- a/Example/TSKitiOSTestApp/TSKitiOSTestApp.xcodeproj/project.pbxproj +++ b/Example/TSKitiOSTestApp/TSKitiOSTestApp.xcodeproj/project.pbxproj @@ -35,8 +35,6 @@ 45AE484F1E072906004D96C2 /* OWSFakeNotificationsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 45AE484E1E072906004D96C2 /* OWSFakeNotificationsManager.m */; }; 45B700971D9841E400269FFD /* OWSDisappearingMessagesConfigurationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45B700961D9841E400269FFD /* OWSDisappearingMessagesConfigurationTest.m */; }; 45B840211D988DA100F9E938 /* OWSReadReceiptTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45B840201D988DA100F9E938 /* OWSReadReceiptTest.m */; }; - 45C5F5A51EE38AB400E1D20D /* OWSFakePreferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 45C5F5A41EE38AB400E1D20D /* OWSFakePreferences.m */; }; - 45C5F5A61EE38AB400E1D20D /* OWSFakePreferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 45C5F5A41EE38AB400E1D20D /* OWSFakePreferences.m */; }; 45C6A09A1D2F029B007D8AC0 /* TSMessageTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45C6A0991D2F029B007D8AC0 /* TSMessageTest.m */; }; 45D7243F1D67899F00E0CA54 /* OWSDeviceProvisionerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45D7243E1D67899F00E0CA54 /* OWSDeviceProvisionerTest.m */; }; 45E741B61E5D14E800735842 /* OWSIncomingMessageFinderTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 45E741B51E5D14E800735842 /* OWSIncomingMessageFinderTest.m */; }; @@ -102,8 +100,6 @@ 45AE484E1E072906004D96C2 /* OWSFakeNotificationsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSFakeNotificationsManager.m; path = ../../../tests/TestSupport/Fakes/OWSFakeNotificationsManager.m; sourceTree = ""; }; 45B700961D9841E400269FFD /* OWSDisappearingMessagesConfigurationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSDisappearingMessagesConfigurationTest.m; path = ../../../tests/Contacts/OWSDisappearingMessagesConfigurationTest.m; sourceTree = ""; }; 45B840201D988DA100F9E938 /* OWSReadReceiptTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSReadReceiptTest.m; path = ../../../tests/Devices/OWSReadReceiptTest.m; sourceTree = ""; }; - 45C5F5A31EE38AB400E1D20D /* OWSFakePreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWSFakePreferences.h; path = ../../../tests/TestSupport/Fakes/OWSFakePreferences.h; sourceTree = ""; }; - 45C5F5A41EE38AB400E1D20D /* OWSFakePreferences.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSFakePreferences.m; path = ../../../tests/TestSupport/Fakes/OWSFakePreferences.m; sourceTree = ""; }; 45C6A0991D2F029B007D8AC0 /* TSMessageTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TSMessageTest.m; path = ../../../tests/Messages/Interactions/TSMessageTest.m; sourceTree = ""; }; 45D7243E1D67899F00E0CA54 /* OWSDeviceProvisionerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSDeviceProvisionerTest.m; path = ../../../tests/Devices/OWSDeviceProvisionerTest.m; sourceTree = ""; }; 45E741B51E5D14E800735842 /* OWSIncomingMessageFinderTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSIncomingMessageFinderTest.m; path = ../../../tests/Messages/OWSIncomingMessageFinderTest.m; sourceTree = ""; }; @@ -173,8 +169,6 @@ 45AE484E1E072906004D96C2 /* OWSFakeNotificationsManager.m */, 452137211E8D6D2F0048FD10 /* OWSFakeMessageSender.h */, 452137221E8D6D2F0048FD10 /* OWSFakeMessageSender.m */, - 45C5F5A31EE38AB400E1D20D /* OWSFakePreferences.h */, - 45C5F5A41EE38AB400E1D20D /* OWSFakePreferences.m */, ); name = Fakes; sourceTree = ""; @@ -549,7 +543,6 @@ buildActionMask = 2147483647; files = ( B6273DDC1C13A2E500738558 /* ViewController.m in Sources */, - 45C5F5A51EE38AB400E1D20D /* OWSFakePreferences.m in Sources */, B6273DD91C13A2E500738558 /* AppDelegate.m in Sources */, B6273DD61C13A2E500738558 /* main.m in Sources */, ); @@ -579,7 +572,6 @@ 45458B7A1CC342B600A02153 /* TSStorageSignedPreKeyStore.m in Sources */, 453E1FDB1DA83EFB00DDD7B7 /* OWSFakeContactsUpdater.m in Sources */, 452137231E8D6D2F0048FD10 /* OWSFakeMessageSender.m in Sources */, - 45C5F5A61EE38AB400E1D20D /* OWSFakePreferences.m in Sources */, D2AECE731DE8C3360068CE15 /* ContactSortingTest.m in Sources */, 453E1FD81DA83E1000DDD7B7 /* OWSFakeContactsManager.m in Sources */, 454021ED1D960ABF00F2126D /* OWSDisappearingMessageFinderTest.m in Sources */, diff --git a/tests/Contacts/TSContactThreadTest.m b/tests/Contacts/TSContactThreadTest.m index 4194f06cb..35aef0e47 100644 --- a/tests/Contacts/TSContactThreadTest.m +++ b/tests/Contacts/TSContactThreadTest.m @@ -3,7 +3,7 @@ // #import "TSContactThread.h" -#import "TSStorageManager+identityKeyStore.h" +#import "OWSIdentityManager.h" #import "OWSUnitTestEnvironment.h" #import @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN { [OWSUnitTestEnvironment ensureSetup]; self.contactThread = [TSContactThread getOrCreateThreadWithContactId:@"fake-contact-id"]; - [self.contactThread.storageManager removeIdentityKeyForRecipient:self.contactThread.contactIdentifier]; + [OWSRecipientIdentity removeAllObjectsInCollection]; } - (void)testHasSafetyNumbersWithoutRemoteIdentity @@ -31,8 +31,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)testHasSafetyNumbersWithRemoteIdentity { - [self.contactThread.storageManager saveRemoteIdentity:[NSData new] - recipientId:self.contactThread.contactIdentifier]; + [[OWSIdentityManager sharedManager] saveRemoteIdentity:[NSData new] + recipientId:self.contactThread.contactIdentifier]; XCTAssert(self.contactThread.hasSafetyNumbers); } diff --git a/tests/Contacts/TSThreadTest.m b/tests/Contacts/TSThreadTest.m index d0fc59240..b355733ae 100644 --- a/tests/Contacts/TSThreadTest.m +++ b/tests/Contacts/TSThreadTest.m @@ -21,7 +21,7 @@ [super setUp]; // Register views, etc. - [[TSStorageManager sharedManager] setupDatabase]; + [[TSStorageManager sharedManager] setupDatabaseWithSafeBlockingMigrations:^{}]; } - (void)tearDown diff --git a/tests/Messages/OWSDisappearingMessageFinderTest.m b/tests/Messages/OWSDisappearingMessageFinderTest.m index c9af8035c..c114790ac 100644 --- a/tests/Messages/OWSDisappearingMessageFinderTest.m +++ b/tests/Messages/OWSDisappearingMessageFinderTest.m @@ -12,16 +12,18 @@ NS_ASSUME_NONNULL_BEGIN @interface OWSDisappearingMessagesFinder (Testing) -- (NSArray *)fetchExpiredMessages; -- (NSArray *)fetchUnstartedExpiringMessagesInThread:(TSThread *)thread; +- (NSArray *)fetchExpiredMessagesWithTransaction:(YapDatabaseReadTransaction *)transaction; +- (NSArray *)fetchUnstartedExpiringMessagesInThread:(TSThread *)thread + transaction:(YapDatabaseReadTransaction *)transaction; @end @interface OWSDisappearingMessageFinderTest : XCTestCase -@property TSStorageManager *storageManager; +@property YapDatabaseConnection *dbConnection; @property OWSDisappearingMessagesFinder *finder; +@property TSStorageManager *storageManager; @property TSThread *thread; @property uint64_t now; @@ -35,13 +37,14 @@ NS_ASSUME_NONNULL_BEGIN [TSMessage removeAllObjectsInCollection]; self.storageManager = [TSStorageManager sharedManager]; + self.dbConnection = self.storageManager.newDatabaseConnection; self.thread = [TSThread new]; [self.thread save]; self.now = [NSDate ows_millisecondTimeStamp]; // Test subject - self.finder = [[OWSDisappearingMessagesFinder alloc] initWithStorageManager:self.storageManager]; - [self.finder blockingRegisterDatabaseExtensions]; + self.finder = [OWSDisappearingMessagesFinder new]; + [OWSDisappearingMessagesFinder blockingRegisterDatabaseExtensions:self.storageManager]; } - (void)testExpiredMessages @@ -90,7 +93,11 @@ NS_ASSUME_NONNULL_BEGIN [[TSMessage alloc] initWithTimestamp:1 inThread:self.thread messageBody:@"unexpiringMessage2"]; [unExpiringMessage2 save]; - NSArray *actualMessages = [self.finder fetchExpiredMessages]; + __block NSArray *actualMessages; + [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction * _Nonnull transaction) { + actualMessages = [self.finder fetchExpiredMessagesWithTransaction:transaction]; + }]; + NSArray *expectedMessages = @[ expiredMessage1, expiredMessage2 ]; XCTAssertEqualObjects(expectedMessages, actualMessages); } @@ -133,15 +140,33 @@ NS_ASSUME_NONNULL_BEGIN [[TSMessage alloc] initWithTimestamp:1 inThread:self.thread messageBody:@"unexpiringMessage2"]; [unExpiringMessage2 save]; - NSArray *actualMessages = [self.finder fetchUnstartedExpiringMessagesInThread:self.thread]; + __block NSArray *actualMessages; + [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction * _Nonnull transaction) { + actualMessages = [self.finder fetchUnstartedExpiringMessagesInThread:self.thread + transaction:transaction]; + }]; + NSArray *expectedMessages = @[ unreadExpiringMessage ]; XCTAssertEqualObjects(expectedMessages, actualMessages); } +- (NSNumber *)nextExpirationTimestamp +{ + __block NSNumber *nextExpirationTimestamp; + + [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction * _Nonnull transaction) { + XCTAssertNotNil(self.finder); + nextExpirationTimestamp = [self.finder nextExpirationTimestampWithTransaction:transaction]; + }]; + + return nextExpirationTimestamp; +} + - (void)testNextExpirationTimestampNilWhenNoExpiringMessages { // Sanity check. - XCTAssertNil(self.finder.nextExpirationTimestamp); + + XCTAssertNil(self.nextExpirationTimestamp); TSMessage *unExpiringMessage = [[TSMessage alloc] initWithTimestamp:1 inThread:self.thread @@ -150,7 +175,7 @@ NS_ASSUME_NONNULL_BEGIN expiresInSeconds:0 expireStartedAt:0]; [unExpiringMessage save]; - XCTAssertNil(self.finder.nextExpirationTimestamp); + XCTAssertNil(self.nextExpirationTimestamp); } - (void)testNextExpirationTimestampNotNilWithUpcomingExpiringMessages @@ -163,8 +188,8 @@ NS_ASSUME_NONNULL_BEGIN expireStartedAt:self.now - 9000]; [soonToExpireMessage save]; - XCTAssertNotNil(self.finder.nextExpirationTimestamp); - XCTAssertEqual(self.now + 1000, [self.finder.nextExpirationTimestamp unsignedLongLongValue]); + XCTAssertNotNil(self.nextExpirationTimestamp); + XCTAssertEqual(self.now + 1000, [self.nextExpirationTimestamp unsignedLongLongValue]); // expired message should take precedence TSMessage *expiredMessage = [[TSMessage alloc] initWithTimestamp:1 @@ -175,8 +200,10 @@ NS_ASSUME_NONNULL_BEGIN expireStartedAt:self.now - 11000]; [expiredMessage save]; - XCTAssertNotNil(self.finder.nextExpirationTimestamp); - XCTAssertEqual(self.now - 1000, [self.finder.nextExpirationTimestamp unsignedLongLongValue]); + //FIXME remove sleep hack in favor of expiringMessage completion handler +// sleep(2); + XCTAssertNotNil(self.nextExpirationTimestamp); + XCTAssertEqual(self.now - 1000, [self.nextExpirationTimestamp unsignedLongLongValue]); } @end diff --git a/tests/Messages/OWSDisappearingMessagesJobTest.m b/tests/Messages/OWSDisappearingMessagesJobTest.m index 1ed0cdf84..a5ea22944 100644 --- a/tests/Messages/OWSDisappearingMessagesJobTest.m +++ b/tests/Messages/OWSDisappearingMessagesJobTest.m @@ -76,6 +76,9 @@ NS_ASSUME_NONNULL_BEGIN // Sanity Check. XCTAssertEqual(4, [TSMessage numberOfKeysInCollection]); [job run]; + + //FIXME remove sleep hack in favor of expiringMessage completion handler + sleep(4); XCTAssertEqual(2, [TSMessage numberOfKeysInCollection]); } diff --git a/tests/Messages/OWSMessageSenderTest.m b/tests/Messages/OWSMessageSenderTest.m index e61bed24b..7a6c4f2cc 100644 --- a/tests/Messages/OWSMessageSenderTest.m +++ b/tests/Messages/OWSMessageSenderTest.m @@ -243,6 +243,8 @@ NS_ASSUME_NONNULL_BEGIN XCTestExpectation *messageStartedExpiration = [self expectationWithDescription:@"messageStartedExpiration"]; [messageSender sendMessage:self.expiringMessage success:^() { + //FIXME remove sleep hack in favor of expiringMessage completion handler + sleep(2); if (self.expiringMessage.expiresAt > 0) { [messageStartedExpiration fulfill]; } else { diff --git a/tests/Messages/TSMessagesManagerTest.m b/tests/Messages/TSMessagesManagerTest.m index 6fbc01a04..4064fef20 100644 --- a/tests/Messages/TSMessagesManagerTest.m +++ b/tests/Messages/TSMessagesManagerTest.m @@ -17,6 +17,7 @@ #import "TSGroupThread.h" #import "TSMessagesManager.h" #import "TSNetworkManager.h" +#import "OWSIdentityManager.h" #import "TSStorageManager.h" #import "OWSUnitTestEnvironment.h" @@ -31,6 +32,7 @@ NS_ASSUME_NONNULL_BEGIN callMessageHandler:(id)callMessageHandler contactsManager:(id)contactsManager contactsUpdater:(ContactsUpdater *)contactsUpdater + identityManager:(OWSIdentityManager *)identityManager messageSender:(OWSMessageSender *)messageSender; // private method we are testing @@ -55,6 +57,7 @@ NS_ASSUME_NONNULL_BEGIN callMessageHandler:[OWSFakeCallMessageHandler new] contactsManager:[OWSFakeContactsManager new] contactsUpdater:[OWSFakeContactsUpdater new] + identityManager:[OWSIdentityManager sharedManager] messageSender:messageSender]; } diff --git a/tests/Storage/OWSOrphanedDataCleanerTest.m b/tests/Storage/OWSOrphanedDataCleanerTest.m index 83eef18d7..996441aa8 100644 --- a/tests/Storage/OWSOrphanedDataCleanerTest.m +++ b/tests/Storage/OWSOrphanedDataCleanerTest.m @@ -20,7 +20,7 @@ { [super setUp]; // Register views, etc. - [[TSStorageManager sharedManager] setupDatabase]; + [[TSStorageManager sharedManager] setupDatabaseWithSafeBlockingMigrations:^{}]; // Set up initial conditions & Sanity check [TSAttachmentStream deleteAttachments]; diff --git a/tests/Storage/TSStorageIdentityKeyStoreTests.m b/tests/Storage/TSStorageIdentityKeyStoreTests.m index 41b2fdd5d..57388b6cf 100644 --- a/tests/Storage/TSStorageIdentityKeyStoreTests.m +++ b/tests/Storage/TSStorageIdentityKeyStoreTests.m @@ -7,7 +7,7 @@ #import "OWSUnitTestEnvironment.h" #import "SecurityUtils.h" -#import "TSStorageManager+IdentityKeyStore.h" +#import "OWSIdentityManager.h" #import "OWSRecipientIdentity.h" #import "TSStorageManager.h" #import "TextSecureKitEnv.h" @@ -34,18 +34,18 @@ NSData *newKey = [SecurityUtils generateRandomBytes:32]; NSString *recipientId = @"test@gmail.com"; - XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId direction:TSMessageDirectionOutgoing]); - XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId direction:TSMessageDirectionIncoming]); + XCTAssert([[OWSIdentityManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId direction:TSMessageDirectionOutgoing]); + XCTAssert([[OWSIdentityManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId direction:TSMessageDirectionIncoming]); } - (void)testAlreadyRegisteredKey { NSData *newKey = [SecurityUtils generateRandomBytes:32]; NSString *recipientId = @"test@gmail.com"; - [[TSStorageManager sharedManager] saveRemoteIdentity:newKey recipientId:recipientId]; + [[OWSIdentityManager sharedManager] saveRemoteIdentity:newKey recipientId:recipientId]; - XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId direction:TSMessageDirectionOutgoing]); - XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId direction:TSMessageDirectionIncoming]); + XCTAssert([[OWSIdentityManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId direction:TSMessageDirectionOutgoing]); + XCTAssert([[OWSIdentityManager sharedManager] isTrustedIdentityKey:newKey recipientId:recipientId direction:TSMessageDirectionIncoming]); } @@ -54,22 +54,22 @@ NSData *originalKey = [SecurityUtils generateRandomBytes:32]; NSString *recipientId = @"test@protonmail.com"; - [[TSStorageManager sharedManager] saveRemoteIdentity:originalKey recipientId:recipientId]; + [[OWSIdentityManager sharedManager] saveRemoteIdentity:originalKey recipientId:recipientId]; - XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:originalKey recipientId:recipientId direction:TSMessageDirectionOutgoing]); - XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:originalKey recipientId:recipientId direction:TSMessageDirectionIncoming]); + XCTAssert([[OWSIdentityManager sharedManager] isTrustedIdentityKey:originalKey recipientId:recipientId direction:TSMessageDirectionOutgoing]); + XCTAssert([[OWSIdentityManager sharedManager] isTrustedIdentityKey:originalKey recipientId:recipientId direction:TSMessageDirectionIncoming]); NSData *otherKey = [SecurityUtils generateRandomBytes:32]; - XCTAssertFalse([[TSStorageManager sharedManager] isTrustedIdentityKey:otherKey recipientId:recipientId direction:TSMessageDirectionOutgoing]); - XCTAssert([[TSStorageManager sharedManager] isTrustedIdentityKey:otherKey recipientId:recipientId direction:TSMessageDirectionIncoming]); + XCTAssertFalse([[OWSIdentityManager sharedManager] isTrustedIdentityKey:otherKey recipientId:recipientId direction:TSMessageDirectionOutgoing]); + XCTAssert([[OWSIdentityManager sharedManager] isTrustedIdentityKey:otherKey recipientId:recipientId direction:TSMessageDirectionIncoming]); } - (void)testIdentityKey { - [[TSStorageManager sharedManager] generateNewIdentityKey]; + [[OWSIdentityManager sharedManager] generateNewIdentityKey]; - XCTAssert([[[TSStorageManager sharedManager] identityKeyPair].publicKey length] == 32); + XCTAssert([[[OWSIdentityManager sharedManager] identityKeyPair].publicKey length] == 32); } @end diff --git a/tests/TestSupport/Fakes/OWSFakePreferences.h b/tests/TestSupport/Fakes/OWSFakePreferences.h deleted file mode 100644 index 51b04bbfa..000000000 --- a/tests/TestSupport/Fakes/OWSFakePreferences.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. -// - -#import -#import "TSPreferences.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface OWSFakePreferences : NSObject - -@end - -NS_ASSUME_NONNULL_END diff --git a/tests/TestSupport/Fakes/OWSFakePreferences.m b/tests/TestSupport/Fakes/OWSFakePreferences.m deleted file mode 100644 index 51a120e34..000000000 --- a/tests/TestSupport/Fakes/OWSFakePreferences.m +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. -// - -#import "OWSFakePreferences.h" - -@implementation OWSFakePreferences - -- (BOOL)isSendingIdentityApprovalRequired -{ - return NO; -} - -@end diff --git a/tests/TestSupport/Fakes/OWSUnitTestEnvironment.m b/tests/TestSupport/Fakes/OWSUnitTestEnvironment.m index d04475749..6209e833a 100644 --- a/tests/TestSupport/Fakes/OWSUnitTestEnvironment.m +++ b/tests/TestSupport/Fakes/OWSUnitTestEnvironment.m @@ -7,7 +7,6 @@ #import "OWSFakeContactsManager.h" #import "OWSFakeMessageSender.h" #import "OWSFakeNotificationsManager.h" -#import "OWSFakePreferences.h" NS_ASSUME_NONNULL_BEGIN @@ -26,8 +25,7 @@ NS_ASSUME_NONNULL_BEGIN return [super initWithCallMessageHandler:[OWSFakeCallMessageHandler new] contactsManager:[OWSFakeContactsManager new] messageSender:[OWSFakeMessageSender new] - notificationsManager:[OWSFakeNotificationsManager new] - preferences:[OWSFakePreferences new]]; + notificationsManager:[OWSFakeNotificationsManager new]]; } @end From 605db6b7887b9f916f50bec2eceef1271761babc Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 28 Jun 2017 17:06:45 -1000 Subject: [PATCH 09/12] Fix up deleteAttachments method since making attachmentFolder dispatchOnce // FREEBIE --- src/Messages/Attachments/TSAttachmentStream.m | 22 +++++++++++++++++-- .../OWSDisappearingMessageFinderTest.m | 5 +++-- tests/Storage/OWSOrphanedDataCleanerTest.m | 4 +++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/Messages/Attachments/TSAttachmentStream.m b/src/Messages/Attachments/TSAttachmentStream.m index f3b1145b6..14860f960 100644 --- a/src/Messages/Attachments/TSAttachmentStream.m +++ b/src/Messages/Attachments/TSAttachmentStream.m @@ -294,10 +294,28 @@ NS_ASSUME_NONNULL_BEGIN + (void)deleteAttachments { NSError *error; - [[NSFileManager defaultManager] removeItemAtPath:[self attachmentsFolder] error:&error]; + + NSFileManager *fileManager = [NSFileManager defaultManager]; + + NSURL *fileURL = [NSURL fileURLWithPath:self.attachmentsFolder]; + NSArray *contents = + [fileManager contentsOfDirectoryAtURL:fileURL includingPropertiesForKeys:nil options:0 error:&error]; + if (error) { - DDLogError(@"Failed to delete attachment folder with error: %@", error.debugDescription); + OWSFail(@"failed to get contents of attachments folder: %@ with error: %@", self.attachmentsFolder, error); + return; } + + for (NSURL *url in contents) { + NSError *deletionError; + [fileManager removeItemAtURL:url error:&deletionError]; + if (deletionError) { + OWSFail(@"failed to remove item at path: %@ with error: %@", filePath, deletionError); + // continue to try to delete remaining items. + } + } + + return; } - (CGSize)calculateImageSize diff --git a/tests/Messages/OWSDisappearingMessageFinderTest.m b/tests/Messages/OWSDisappearingMessageFinderTest.m index c114790ac..1fe22aedc 100644 --- a/tests/Messages/OWSDisappearingMessageFinderTest.m +++ b/tests/Messages/OWSDisappearingMessageFinderTest.m @@ -1,5 +1,6 @@ -// Created by Michael Kirk on 9/23/16. -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "NSDate+millisecondTimeStamp.h" #import "OWSDisappearingMessagesFinder.h" diff --git a/tests/Storage/OWSOrphanedDataCleanerTest.m b/tests/Storage/OWSOrphanedDataCleanerTest.m index 996441aa8..0f4bb7fff 100644 --- a/tests/Storage/OWSOrphanedDataCleanerTest.m +++ b/tests/Storage/OWSOrphanedDataCleanerTest.m @@ -76,6 +76,9 @@ - (void)testFilesWithoutInteractionsAreDeleted { + // sanity check + XCTAssertEqual(0, [TSAttachmentStream numberOfItemsInAttachmentsFolder]); + NSError *error; TSAttachmentStream *attachmentStream = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg" sourceFilename:nil]; [attachmentStream writeData:[NSData new] error:&error]; @@ -129,7 +132,6 @@ [attachmentStream writeData:[NSData new] error:&error]; // Intentionally not saved, because we want a lingering file. - NSString *orphanedFilePath = [attachmentStream filePath]; BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:orphanedFilePath]; XCTAssert(fileExists); From a8ea2428c6f97edd6f745fa00d7429ccb586f29e Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 28 Jun 2017 17:39:35 -1000 Subject: [PATCH 10/12] gemfile for consistent build on dev/CI // FREEBIE --- .travis.yml | 4 +- Gemfile | 5 ++ Gemfile.lock | 187 +++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 2 +- 4 files changed, 195 insertions(+), 3 deletions(-) create mode 100644 Gemfile create mode 100644 Gemfile.lock diff --git a/.travis.yml b/.travis.yml index 78c2f4ba2..4d6888eb8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,8 @@ env: before_install: - brew update - - gem install cocoapods xcpretty --no-ri --no-rdoc - - pod repo update --silent + - bundle + - bundle exec pod repo update --silent after_failure: - sleep 10 # This prevents the occasional output truncation that happens when piping to xcpretty. diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..145a78f3b --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gem 'fastlane' +gem 'cocoapods' + diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..34e549c93 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,187 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.3.5) + activesupport (4.2.8) + i18n (~> 0.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + addressable (2.5.1) + public_suffix (~> 2.0, >= 2.0.2) + babosa (1.0.2) + claide (1.0.1) + cocoapods (1.2.1) + activesupport (>= 4.0.2, < 5) + claide (>= 1.0.1, < 2.0) + cocoapods-core (= 1.2.1) + cocoapods-deintegrate (>= 1.0.1, < 2.0) + cocoapods-downloader (>= 1.1.3, < 2.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-stats (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.2.0, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (~> 2.0.1) + gh_inspector (~> 1.0) + molinillo (~> 0.5.7) + nap (~> 1.0) + ruby-macho (~> 1.1) + xcodeproj (>= 1.4.4, < 2.0) + cocoapods-core (1.2.1) + activesupport (>= 4.0.2, < 5) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + cocoapods-deintegrate (1.0.1) + cocoapods-downloader (1.1.3) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.0) + cocoapods-stats (1.0.0) + cocoapods-trunk (1.2.0) + nap (>= 0.8, < 2.0) + netrc (= 0.7.8) + cocoapods-try (1.1.0) + colored (1.2) + colored2 (3.1.2) + commander-fastlane (4.4.4) + highline (~> 1.7.2) + domain_name (0.5.20170404) + unf (>= 0.0.5, < 1.0.0) + dotenv (2.2.0) + escape (0.0.4) + excon (0.55.0) + faraday (0.12.0.1) + multipart-post (>= 1.2, < 3) + faraday-cookie_jar (0.0.6) + faraday (>= 0.7.4) + http-cookie (~> 1.0.0) + faraday_middleware (0.11.0.1) + faraday (>= 0.7.4, < 1.0) + fastimage (2.1.0) + fastlane (2.27.0) + addressable (>= 2.3, < 3.0.0) + babosa (>= 1.0.2, < 2.0.0) + bundler (>= 1.12.0, < 2.0.0) + colored + commander-fastlane (>= 4.4.0, < 5.0.0) + dotenv (>= 2.1.1, < 3.0.0) + excon (>= 0.45.0, < 1.0.0) + faraday (~> 0.9) + faraday-cookie_jar (~> 0.0.6) + faraday_middleware (~> 0.9) + fastimage (>= 1.6) + gh_inspector (>= 1.0.1, < 2.0.0) + google-api-client (~> 0.9.2) + highline (>= 1.7.2, < 2.0.0) + json (< 3.0.0) + mini_magick (~> 4.5.1) + multi_json + multi_xml (~> 0.5) + multipart-post (~> 2.0.0) + plist (>= 3.1.0, < 4.0.0) + rubyzip (>= 1.1.0, < 2.0.0) + security (= 0.1.3) + slack-notifier (>= 1.3, < 2.0.0) + terminal-notifier (>= 1.6.2, < 2.0.0) + terminal-table (>= 1.4.5, < 2.0.0) + tty-screen (~> 0.5.0) + word_wrap (~> 1.0.0) + xcodeproj (>= 1.4.4, < 2.0.0) + xcpretty (>= 0.2.4, < 1.0.0) + xcpretty-travis-formatter (>= 0.0.3) + fourflusher (2.0.1) + fuzzy_match (2.0.4) + gh_inspector (1.0.3) + google-api-client (0.9.28) + addressable (~> 2.3) + googleauth (~> 0.5) + httpclient (~> 2.7) + hurley (~> 0.1) + memoist (~> 0.11) + mime-types (>= 1.6) + representable (~> 2.3.0) + retriable (~> 2.0) + googleauth (0.5.1) + faraday (~> 0.9) + jwt (~> 1.4) + logging (~> 2.0) + memoist (~> 0.12) + multi_json (~> 1.11) + os (~> 0.9) + signet (~> 0.7) + highline (1.7.8) + http-cookie (1.0.3) + domain_name (~> 0.5) + httpclient (2.8.3) + hurley (0.2) + i18n (0.8.1) + json (2.0.4) + jwt (1.5.6) + little-plugger (1.1.4) + logging (2.2.2) + little-plugger (~> 1.1) + multi_json (~> 1.10) + memoist (0.15.0) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + mini_magick (4.5.1) + minitest (5.10.1) + molinillo (0.5.7) + multi_json (1.12.1) + multi_xml (0.6.0) + multipart-post (2.0.0) + nanaimo (0.2.3) + nap (1.1.0) + netrc (0.7.8) + os (0.9.6) + plist (3.2.0) + public_suffix (2.0.5) + representable (2.3.0) + uber (~> 0.0.7) + retriable (2.1.0) + rouge (1.11.1) + ruby-macho (1.1.0) + rubyzip (1.2.1) + security (0.1.3) + signet (0.7.3) + addressable (~> 2.3) + faraday (~> 0.9) + jwt (~> 1.5) + multi_json (~> 1.10) + slack-notifier (1.5.1) + terminal-notifier (1.7.1) + terminal-table (1.7.3) + unicode-display_width (~> 1.1.1) + thread_safe (0.3.6) + tty-screen (0.5.0) + tzinfo (1.2.3) + thread_safe (~> 0.1) + uber (0.0.15) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.3) + unicode-display_width (1.1.3) + word_wrap (1.0.0) + xcodeproj (1.4.4) + CFPropertyList (~> 2.3.3) + claide (>= 1.0.1, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.2.3) + xcpretty (0.2.6) + rouge (~> 1.8) + xcpretty-travis-formatter (0.0.4) + xcpretty (~> 0.2, >= 0.0.7) + +PLATFORMS + ruby + +DEPENDENCIES + cocoapods + fastlane + +BUNDLED WITH + 1.14.6 diff --git a/Makefile b/Makefile index d4c3d2a69..a259bdd3d 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ test: pod_install retest pod_install: cd $(WORKING_DIR) && \ - pod install + bundle exec pod install build: pod_install cd $(WORKING_DIR) && \ From acf31db4b3848685403e0febff9b5cc6bdebb47d Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 28 Jun 2017 18:04:25 -1000 Subject: [PATCH 11/12] bump travis image to 8.3 // FREEBIE --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4d6888eb8..b2713ea3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: objective-c -osx_image: xcode8 +osx_image: xcode8.3 env: -EARLY_START_SIMULATOR=1 # early starting simulator reduces false negatives due to test timeouts From 0b33ef61618c9158c948100be7b1d3d95c5147ce Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 28 Jun 2017 18:12:55 -1000 Subject: [PATCH 12/12] try fastlane scan, since build is timing out. // FREEBIE --- .travis.yml | 2 +- Makefile | 5 +++++ fastlane/.gitignore | 1 + fastlane/Scanfile | 8 ++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 fastlane/.gitignore create mode 100644 fastlane/Scanfile diff --git a/.travis.yml b/.travis.yml index b2713ea3d..e8235d5ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,5 +13,5 @@ before_install: after_failure: - sleep 10 # This prevents the occasional output truncation that happens when piping to xcpretty. -script: make +script: make scan_test diff --git a/Makefile b/Makefile index a259bdd3d..7dd3f196a 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,8 @@ default: test test: pod_install retest +scan_test: pod_install scan + pod_install: cd $(WORKING_DIR) && \ bundle exec pod install @@ -28,6 +30,9 @@ retest: optional_early_start_simulator -destination '${BUILD_DESTINATION}' \ test | xcpretty +scan: + bundle exec fastlane scan + clean: cd $(WORKING_DIR) && \ $(XCODE_BUILD) \ diff --git a/fastlane/.gitignore b/fastlane/.gitignore new file mode 100644 index 000000000..007b73ee6 --- /dev/null +++ b/fastlane/.gitignore @@ -0,0 +1 @@ +test_output diff --git a/fastlane/Scanfile b/fastlane/Scanfile new file mode 100644 index 000000000..92d36a875 --- /dev/null +++ b/fastlane/Scanfile @@ -0,0 +1,8 @@ +# For more information about this configuration visit +# https://github.com/fastlane/fastlane/tree/master/scan#scanfile + +workspace "Example/TSKitiOSTestApp/TSKitiOSTestApp.xcworkspace" +scheme "TSKitiOSTestApp" + +devices ["iPhone SE"] +