Merge branch 'charlesmchen/buildBreakage'
This commit is contained in:
commit
dbaa49d2f9
|
@ -18,10 +18,10 @@ enum PushNotificationRequestResult: String {
|
|||
}
|
||||
|
||||
class FailingTSAccountManager: TSAccountManager {
|
||||
override public init(networkManager: TSNetworkManager, primaryStorage: OWSPrimaryStorage) {
|
||||
override public init(primaryStorage: OWSPrimaryStorage) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
super.init(networkManager: networkManager, primaryStorage: primaryStorage)
|
||||
super.init(primaryStorage: primaryStorage)
|
||||
|
||||
self.phoneNumberAwaitingVerification = "+13235555555"
|
||||
}
|
||||
|
@ -47,10 +47,6 @@ class VerifyingTSAccountManager: FailingTSAccountManager {
|
|||
success: @escaping () -> Void, failure: @escaping (Error) -> Void) {
|
||||
success()
|
||||
}
|
||||
|
||||
override func registerForManualMessageFetching(success successBlock: @escaping () -> Void, failure failureBlock: @escaping (Error) -> Void) {
|
||||
successBlock()
|
||||
}
|
||||
}
|
||||
|
||||
class TokenObtainingTSAccountManager: VerifyingTSAccountManager {
|
||||
|
@ -58,11 +54,20 @@ class TokenObtainingTSAccountManager: VerifyingTSAccountManager {
|
|||
|
||||
class AccountManagerTest: SignalBaseTest {
|
||||
|
||||
let tsAccountManager = FailingTSAccountManager(networkManager: TSNetworkManager.shared(), primaryStorage: OWSPrimaryStorage.shared())
|
||||
var preferences = OWSPreferences()
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
let tsAccountManager = FailingTSAccountManager(primaryStorage: OWSPrimaryStorage.shared())
|
||||
let sskEnvironment = SSKEnvironment.shared as! MockSSKEnvironment
|
||||
sskEnvironment.tsAccountManager = tsAccountManager
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testRegisterWhenEmptyCode() {
|
||||
let accountManager = AccountManager(textSecureAccountManager: tsAccountManager, preferences: self.preferences)
|
||||
let accountManager = AccountManager()
|
||||
|
||||
let expectation = self.expectation(description: "should fail")
|
||||
|
||||
|
@ -83,7 +88,7 @@ class AccountManagerTest: SignalBaseTest {
|
|||
}
|
||||
|
||||
func testRegisterWhenVerificationFails() {
|
||||
let accountManager = AccountManager(textSecureAccountManager: tsAccountManager, preferences: self.preferences)
|
||||
let accountManager = AccountManager()
|
||||
|
||||
let expectation = self.expectation(description: "should fail")
|
||||
|
||||
|
@ -103,9 +108,11 @@ class AccountManagerTest: SignalBaseTest {
|
|||
}
|
||||
|
||||
func testSuccessfulRegistration() {
|
||||
let tsAccountManager = TokenObtainingTSAccountManager(networkManager: TSNetworkManager.shared(), primaryStorage: OWSPrimaryStorage.shared())
|
||||
let tsAccountManager = TokenObtainingTSAccountManager(primaryStorage: OWSPrimaryStorage.shared())
|
||||
let sskEnvironment = SSKEnvironment.shared as! MockSSKEnvironment
|
||||
sskEnvironment.tsAccountManager = tsAccountManager
|
||||
|
||||
let accountManager = AccountManager(textSecureAccountManager: tsAccountManager, preferences: self.preferences)
|
||||
let accountManager = AccountManager()
|
||||
|
||||
let expectation = self.expectation(description: "should succeed")
|
||||
|
||||
|
@ -121,7 +128,7 @@ class AccountManagerTest: SignalBaseTest {
|
|||
}
|
||||
|
||||
func testUpdatePushTokens() {
|
||||
let accountManager = AccountManager(textSecureAccountManager: tsAccountManager, preferences: self.preferences)
|
||||
let accountManager = AccountManager()
|
||||
|
||||
let expectation = self.expectation(description: "should fail")
|
||||
|
||||
|
|
|
@ -68,9 +68,9 @@ class SSKProtoEnvelopeTest: SignalBaseTest {
|
|||
|
||||
func testParse_roundtrip() {
|
||||
let builder = SSKProtoEnvelope.builder(type: SSKProtoEnvelope.SSKProtoEnvelopeType.prekeyBundle,
|
||||
source: "+13213214321",
|
||||
sourceDevice: 1,
|
||||
timestamp: 123)
|
||||
builder.setSource("+13213214321")
|
||||
builder.setSourceDevice(1)
|
||||
|
||||
let phonyContent = "phony data".data(using: .utf8)!
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
SetCurrentAppContext([TestAppContext new]);
|
||||
|
||||
[MockEnvironment activate];
|
||||
[MockSSKEnvironment activate];
|
||||
[MockEnvironment activate];
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
|
|
|
@ -12,6 +12,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (instancetype)init;
|
||||
|
||||
@property (nonatomic) OWSContactsManager *contactsManager;
|
||||
@property (nonatomic) OWSPreferences *preferences;
|
||||
@property (nonatomic) OWSContactsSyncing *contactsSyncing;
|
||||
@property (nonatomic) OWSSounds *sounds;
|
||||
@property (nonatomic) LockInteractionController *lockInteractionController;
|
||||
@property (nonatomic) OWSWindowManager *windowManager;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -9,6 +9,19 @@
|
|||
|
||||
static Environment *sharedEnvironment = nil;
|
||||
|
||||
@interface Environment ()
|
||||
|
||||
@property (nonatomic) OWSContactsManager *contactsManager;
|
||||
@property (nonatomic) OWSPreferences *preferences;
|
||||
@property (nonatomic) OWSContactsSyncing *contactsSyncing;
|
||||
@property (nonatomic) OWSSounds *sounds;
|
||||
@property (nonatomic) LockInteractionController *lockInteractionController;
|
||||
@property (nonatomic) OWSWindowManager *windowManager;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation Environment
|
||||
|
||||
+ (Environment *)shared
|
||||
|
|
|
@ -16,6 +16,10 @@ extern NSString *const kNSNotificationName_IdentityStateDidChange;
|
|||
// number of bytes in a signal identity key, excluding the key-type byte.
|
||||
extern const NSUInteger kIdentityKeyLength;
|
||||
|
||||
#ifdef DEBUG
|
||||
extern const NSUInteger kStoredIdentityKeyLength;
|
||||
#endif
|
||||
|
||||
@class OWSRecipientIdentity;
|
||||
@class OWSStorage;
|
||||
@class SSKProtoVerified;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern const NSUInteger kGroupIdLength;
|
||||
extern const int32_t kGroupIdLength;
|
||||
|
||||
@interface TSGroupModel : TSYapDatabaseObject
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
const NSUInteger kGroupIdLength = 16;
|
||||
const int32_t kGroupIdLength = 16;
|
||||
|
||||
@interface TSGroupModel ()
|
||||
|
||||
|
|
|
@ -70,9 +70,12 @@ public class OWSUDManagerImpl: NSObject, OWSUDManager {
|
|||
// MARK: Recipient State
|
||||
private let kUnidentifiedAccessCollection = "kUnidentifiedAccessCollection"
|
||||
|
||||
var certificateValidator: SMKCertificateValidator
|
||||
|
||||
@objc
|
||||
public required init(primaryStorage: OWSPrimaryStorage) {
|
||||
self.dbConnection = primaryStorage.newDatabaseConnection()
|
||||
self.certificateValidator = SMKCertificateDefaultValidator(trustRoot: OWSUDManagerImpl.trustRoot())
|
||||
|
||||
super.init()
|
||||
|
||||
|
@ -281,8 +284,6 @@ public class OWSUDManagerImpl: NSObject, OWSUDManager {
|
|||
let anHourFromNowMs = nowMs + kHourInMs
|
||||
|
||||
do {
|
||||
let certificateValidator = SMKCertificateDefaultValidator(trustRoot: trustRoot())
|
||||
|
||||
try certificateValidator.validate(senderCertificate: certificate, validationTime: anHourFromNowMs)
|
||||
return true
|
||||
} catch {
|
||||
|
@ -298,6 +299,11 @@ public class OWSUDManagerImpl: NSObject, OWSUDManager {
|
|||
|
||||
@objc
|
||||
public func trustRoot() -> ECPublicKey {
|
||||
return OWSUDManagerImpl.trustRoot()
|
||||
}
|
||||
|
||||
@objc
|
||||
public class func trustRoot() -> ECPublicKey {
|
||||
guard let trustRootData = NSData(fromBase64String: kUDTrustRoot) else {
|
||||
// This exits.
|
||||
owsFail("Invalid trust root data.")
|
||||
|
|
|
@ -21,6 +21,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property (nonatomic) OWSMessageManager *messageManager;
|
||||
@property (nonatomic) OWSBlockingManager *blockingManager;
|
||||
@property (nonatomic) OWSIdentityManager *identityManager;
|
||||
@property (nonatomic) id<OWSUDManager> udManager;
|
||||
@property (nonatomic) OWSMessageDecrypter *messageDecrypter;
|
||||
@property (nonatomic) OWSBatchMessageProcessor *batchMessageProcessor;
|
||||
@property (nonatomic) OWSMessageReceiver *messageReceiver;
|
||||
@property (nonatomic) TSSocketManager *socketManager;
|
||||
@property (nonatomic) TSAccountManager *tsAccountManager;
|
||||
@property (nonatomic) OWS2FAManager *ows2FAManager;
|
||||
@property (nonatomic) OWSDisappearingMessagesJob *disappearingMessagesJob;
|
||||
@property (nonatomic) ContactDiscoveryService *contactDiscoveryService;
|
||||
@property (nonatomic) OWSReadReceiptManager *readReceiptManager;
|
||||
@property (nonatomic) OWSOutgoingReceiptManager *outgoingReceiptManager;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -61,6 +61,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
OWSAssertIsOnMainThread();
|
||||
OWSAssertDebug(block);
|
||||
|
||||
if (CurrentAppContext().isRunningTests) {
|
||||
// We don't need to an any "on app ready" work
|
||||
// in the tests.
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.isAppReady) {
|
||||
block();
|
||||
return;
|
||||
|
@ -93,6 +99,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
NSArray<AppReadyBlock> *appReadyBlocks = [self.appReadyBlocks copy];
|
||||
[self.appReadyBlocks removeAllObjects];
|
||||
|
||||
for (AppReadyBlock block in appReadyBlocks) {
|
||||
block();
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSContactThread.h"
|
||||
#import "MockSSKEnvironment.h"
|
||||
#import "OWSIdentityManager.h"
|
||||
#import "SSKBaseTestObjC.h"
|
||||
#import "TSContactThread.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (void)testHasSafetyNumbersWithRemoteIdentity
|
||||
{
|
||||
[[OWSIdentityManager sharedManager] saveRemoteIdentity:[NSData new]
|
||||
[[OWSIdentityManager sharedManager] saveRemoteIdentity:[[NSMutableData alloc] initWithLength:kStoredIdentityKeyLength]
|
||||
recipientId:self.contactThread.contactIdentifier];
|
||||
XCTAssert(self.contactThread.hasSafetyNumbers);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@
|
|||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
serverTimestamp:nil];
|
||||
serverTimestamp:nil
|
||||
wasReceivedByUD:NO];
|
||||
[incomingMessage save];
|
||||
|
||||
TSOutgoingMessage *outgoingMessage =
|
||||
|
@ -102,7 +103,8 @@
|
|||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
serverTimestamp:nil];
|
||||
serverTimestamp:nil
|
||||
wasReceivedByUD:NO];
|
||||
[incomingMessage save];
|
||||
|
||||
TSAttachmentStream *outgoingAttachment =
|
||||
|
|
|
@ -55,7 +55,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expiresInSeconds:0
|
||||
quotedMessage:nil
|
||||
contactShare:nil
|
||||
serverTimestamp:nil];
|
||||
serverTimestamp:nil
|
||||
wasReceivedByUD:NO];
|
||||
[incomingMessage save];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue