mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			50 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Objective-C
		
	
			
		
		
	
	
			50 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Objective-C
		
	
| #import "SessionDescriptorTest.h"
 | |
| #import "InitiatorSessionDescriptor.h"
 | |
| #import "ResponderSessionDescriptor.h"
 | |
| #import "TestUtil.h"
 | |
| #import "Util.h"
 | |
| 
 | |
| @implementation SessionDescriptorTest
 | |
| 
 | |
| -(void) testInitiatorSessionDescriptionJson {
 | |
|     InitiatorSessionDescriptor* d = [InitiatorSessionDescriptor initiatorSessionDescriptorWithSessionId:5
 | |
|                                                                                      andRelayServerName:@"example.com"
 | |
|                                                                                            andRelayPort:6];
 | |
|     test([d sessionId] == 5);
 | |
|     test([d relayUdpPort] == 6);
 | |
|     test([[d relayServerName] isEqualToString:@"example.com"]);
 | |
|     
 | |
|     // roundtrip
 | |
|     InitiatorSessionDescriptor* d2 = [InitiatorSessionDescriptor initiatorSessionDescriptorFromJson:[d toJson]];
 | |
|     test([d2 sessionId] == 5);
 | |
|     test([d2 relayUdpPort] == 6);
 | |
|     test([[d2 relayServerName] isEqualToString:@"example.com"]);
 | |
|     
 | |
|     // constant
 | |
|     InitiatorSessionDescriptor* d3 = [InitiatorSessionDescriptor initiatorSessionDescriptorFromJson:@"{\"sessionId\":5,\"serverName\":\"example.com\",\"relayPort\":6}"];
 | |
|     test([d3 sessionId] == 5);
 | |
|     test([d3 relayUdpPort] == 6);
 | |
|     test([[d3 relayServerName] isEqualToString:@"example.com"]);
 | |
| }
 | |
| 
 | |
| -(void) testResponderSessionDescriptorFromEncryptedRemoteNotification2 {
 | |
|     NSDictionary* notification = @{
 | |
|                                    @"aps":@{@"alert":@"Incoming Call!"},
 | |
|                                    @"m":@"AJV74NzwSbZ1KeV4pRwPfMZQ3a5n0V0/HV7eABUUCJvRVqGe3qFO/2XHKv1nEDwNg2naQDmd/nLOlvk="
 | |
|                                    };
 | |
|     
 | |
|     [Environment setCurrent:testEnv];
 | |
|     [[Environment preferences] setValueForKey:@"Signaling Mac Key" toValue:[@"0000000000000000000000000000000000000000" decodedAsHexString]];
 | |
|     [[Environment preferences] setValueForKey:@"Signaling Cipher Key" toValue:[@"00000000000000000000000000000000" decodedAsHexString]];
 | |
|     
 | |
|     ResponderSessionDescriptor* d = [ResponderSessionDescriptor responderSessionDescriptorFromEncryptedRemoteNotification:notification];
 | |
|   
 | |
|     test(d.interopVersion == 1);
 | |
|     test(d.relayUdpPort == 11235);
 | |
|     test(d.sessionId == 2357);
 | |
|     test([d.relayServerName isEqualToString:@"Test"]);
 | |
|     test([[d.initiatorNumber toE164] isEqualToString:@"+19027777777"]);
 | |
| }
 | |
| 
 | |
| @end
 |