mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Fix some more tests.
Adapt to IdentityManager refactor Adapt to DisappearingMessages refactor // FREEBIE
This commit is contained in:
parent
8f9af85cca
commit
1d71ca5e50
13 changed files with 72 additions and 74 deletions
|
@ -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
|
||||
|
|
|
@ -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 = "<group>"; };
|
||||
45B700961D9841E400269FFD /* OWSDisappearingMessagesConfigurationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSDisappearingMessagesConfigurationTest.m; path = ../../../tests/Contacts/OWSDisappearingMessagesConfigurationTest.m; sourceTree = "<group>"; };
|
||||
45B840201D988DA100F9E938 /* OWSReadReceiptTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSReadReceiptTest.m; path = ../../../tests/Devices/OWSReadReceiptTest.m; sourceTree = "<group>"; };
|
||||
45C5F5A31EE38AB400E1D20D /* OWSFakePreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWSFakePreferences.h; path = ../../../tests/TestSupport/Fakes/OWSFakePreferences.h; sourceTree = "<group>"; };
|
||||
45C5F5A41EE38AB400E1D20D /* OWSFakePreferences.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSFakePreferences.m; path = ../../../tests/TestSupport/Fakes/OWSFakePreferences.m; sourceTree = "<group>"; };
|
||||
45C6A0991D2F029B007D8AC0 /* TSMessageTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TSMessageTest.m; path = ../../../tests/Messages/Interactions/TSMessageTest.m; sourceTree = "<group>"; };
|
||||
45D7243E1D67899F00E0CA54 /* OWSDeviceProvisionerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSDeviceProvisionerTest.m; path = ../../../tests/Devices/OWSDeviceProvisionerTest.m; sourceTree = "<group>"; };
|
||||
45E741B51E5D14E800735842 /* OWSIncomingMessageFinderTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSIncomingMessageFinderTest.m; path = ../../../tests/Messages/OWSIncomingMessageFinderTest.m; sourceTree = "<group>"; };
|
||||
|
@ -173,8 +169,6 @@
|
|||
45AE484E1E072906004D96C2 /* OWSFakeNotificationsManager.m */,
|
||||
452137211E8D6D2F0048FD10 /* OWSFakeMessageSender.h */,
|
||||
452137221E8D6D2F0048FD10 /* OWSFakeMessageSender.m */,
|
||||
45C5F5A31EE38AB400E1D20D /* OWSFakePreferences.h */,
|
||||
45C5F5A41EE38AB400E1D20D /* OWSFakePreferences.m */,
|
||||
);
|
||||
name = Fakes;
|
||||
sourceTree = "<group>";
|
||||
|
@ -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 */,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
|
||||
#import "TSContactThread.h"
|
||||
#import "TSStorageManager+identityKeyStore.h"
|
||||
#import "OWSIdentityManager.h"
|
||||
#import "OWSUnitTestEnvironment.h"
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
[super setUp];
|
||||
|
||||
// Register views, etc.
|
||||
[[TSStorageManager sharedManager] setupDatabase];
|
||||
[[TSStorageManager sharedManager] setupDatabaseWithSafeBlockingMigrations:^{}];
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
|
|
|
@ -12,16 +12,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface OWSDisappearingMessagesFinder (Testing)
|
||||
|
||||
- (NSArray<TSMessage *> *)fetchExpiredMessages;
|
||||
- (NSArray<TSMessage *> *)fetchUnstartedExpiringMessagesInThread:(TSThread *)thread;
|
||||
- (NSArray<TSMessage *> *)fetchExpiredMessagesWithTransaction:(YapDatabaseReadTransaction *)transaction;
|
||||
- (NSArray<TSMessage *> *)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<TSMessage *> *actualMessages = [self.finder fetchExpiredMessages];
|
||||
__block NSArray<TSMessage *> *actualMessages;
|
||||
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction * _Nonnull transaction) {
|
||||
actualMessages = [self.finder fetchExpiredMessagesWithTransaction:transaction];
|
||||
}];
|
||||
|
||||
NSArray<TSMessage *> *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<TSMessage *> *actualMessages = [self.finder fetchUnstartedExpiringMessagesInThread:self.thread];
|
||||
__block NSArray<TSMessage *> *actualMessages;
|
||||
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction * _Nonnull transaction) {
|
||||
actualMessages = [self.finder fetchUnstartedExpiringMessagesInThread:self.thread
|
||||
transaction:transaction];
|
||||
}];
|
||||
|
||||
NSArray<TSMessage *> *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
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<OWSCallMessageHandler>)callMessageHandler
|
||||
contactsManager:(id<ContactsManagerProtocol>)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];
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
{
|
||||
[super setUp];
|
||||
// Register views, etc.
|
||||
[[TSStorageManager sharedManager] setupDatabase];
|
||||
[[TSStorageManager sharedManager] setupDatabaseWithSafeBlockingMigrations:^{}];
|
||||
|
||||
// Set up initial conditions & Sanity check
|
||||
[TSAttachmentStream deleteAttachments];
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "TSPreferences.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSFakePreferences : NSObject <TSPreferences>
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -1,14 +0,0 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSFakePreferences.h"
|
||||
|
||||
@implementation OWSFakePreferences
|
||||
|
||||
- (BOOL)isSendingIdentityApprovalRequired
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue