mirror of https://github.com/oxen-io/session-ios
				
				
				
			Fix up some tests
Included plausible test implementation for an in-memory profile manager. Note two tests remain failing (they've been failing for a while) // FREEBIEpull/1/head
							parent
							
								
									620550a462
								
							
						
					
					
						commit
						40b99a15ed
					
				@ -0,0 +1,13 @@
 | 
			
		||||
//
 | 
			
		||||
//  Copyright (c) 2017 Open Whisper Systems. All rights reserved.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#import "ProfileManagerProtocol.h"
 | 
			
		||||
 | 
			
		||||
NS_ASSUME_NONNULL_BEGIN
 | 
			
		||||
 | 
			
		||||
@interface OWSFakeProfileManager : NSObject <ProfileManagerProtocol>
 | 
			
		||||
 | 
			
		||||
@end
 | 
			
		||||
 | 
			
		||||
NS_ASSUME_NONNULL_END
 | 
			
		||||
@ -0,0 +1,62 @@
 | 
			
		||||
//
 | 
			
		||||
//  Copyright (c) 2017 Open Whisper Systems. All rights reserved.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#import "OWSFakeProfileManager.h"
 | 
			
		||||
#import "TSThread.h"
 | 
			
		||||
 | 
			
		||||
NS_ASSUME_NONNULL_BEGIN
 | 
			
		||||
 | 
			
		||||
@interface OWSFakeProfileManager ()
 | 
			
		||||
 | 
			
		||||
@property (nonatomic, readonly) NSMutableDictionary<NSString *, NSData *> *profileKeys;
 | 
			
		||||
@property (nonatomic, readonly) NSMutableSet<NSString *> *recipientWhitelist;
 | 
			
		||||
@property (nonatomic, readonly) NSMutableSet<NSString *> *threadWhitelist;
 | 
			
		||||
 | 
			
		||||
@end
 | 
			
		||||
 | 
			
		||||
@implementation OWSFakeProfileManager
 | 
			
		||||
 | 
			
		||||
- (instancetype)init
 | 
			
		||||
{
 | 
			
		||||
    self = [super init];
 | 
			
		||||
    if (!self) {
 | 
			
		||||
        return self;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _profileKeys = [NSMutableDictionary new];
 | 
			
		||||
    _recipientWhitelist = [NSMutableSet new];
 | 
			
		||||
    _threadWhitelist = [NSMutableSet new];
 | 
			
		||||
 | 
			
		||||
    return self;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- (NSData *)localProfileKey
 | 
			
		||||
{
 | 
			
		||||
    return [@"fake-local-profile-key-for-testing" dataUsingEncoding:NSUTF8StringEncoding];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
- (void)setProfileKey:(NSData *)profileKey forRecipientId:(NSString *)recipientId
 | 
			
		||||
{
 | 
			
		||||
    self.profileKeys[recipientId] = profileKey;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
- (BOOL)isUserInProfileWhitelist:(NSString *)recipientId
 | 
			
		||||
{
 | 
			
		||||
    return [self.recipientWhitelist containsObject:recipientId];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
- (BOOL)isThreadInProfileWhitelist:(TSThread *)thread
 | 
			
		||||
{
 | 
			
		||||
    return [self.threadWhitelist containsObject:thread.uniqueId];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
- (void)addUserToProfileWhitelist:(NSString *)recipientId
 | 
			
		||||
{
 | 
			
		||||
    [self.recipientWhitelist addObject:recipientId];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@end
 | 
			
		||||
 | 
			
		||||
NS_ASSUME_NONNULL_END
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue