mirror of https://github.com/oxen-io/session-ios
Integrate with new contact discovery endpoint
Also: * use system cookie parsing * add AESGCM additional authenticated data parameter // FREEBIEpull/1/head
parent
a611625691
commit
b42f528713
@ -1 +1 @@
|
|||||||
Subproject commit a2394bbafc099db434ee91e7a617c412750c44b9
|
Subproject commit 5dc9c23dc3229ab6a884372a0e2cf62cb0904be6
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
@testable import SignalServiceKit
|
||||||
|
|
||||||
|
class ContactDiscoveryOperationTest: XCTestCase {
|
||||||
|
|
||||||
|
override func setUp() {
|
||||||
|
super.setUp()
|
||||||
|
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||||
|
}
|
||||||
|
|
||||||
|
override func tearDown() {
|
||||||
|
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||||
|
super.tearDown()
|
||||||
|
}
|
||||||
|
|
||||||
|
func tesBoolArrayFromEmptyData() {
|
||||||
|
let data = Data()
|
||||||
|
let bools = CDSBatchOperation.boolArray(data: data)
|
||||||
|
XCTAssert(bools == [])
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBoolArrayFromFalseByte() {
|
||||||
|
let data = Data(repeating: 0x00, count: 4)
|
||||||
|
let bools = CDSBatchOperation.boolArray(data: data)
|
||||||
|
XCTAssert(bools == [false, false, false, false])
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBoolArrayFromTrueByte() {
|
||||||
|
let data = Data(repeating: 0x01, count: 4)
|
||||||
|
let bools = CDSBatchOperation.boolArray(data: data)
|
||||||
|
XCTAssert(bools == [true, true, true, true])
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBoolArrayFromMixedBytes() {
|
||||||
|
let data = Data(bytes: [0x01, 0x00, 0x01, 0x01])
|
||||||
|
let bools = CDSBatchOperation.boolArray(data: data)
|
||||||
|
XCTAssert(bools == [true, false, true, true])
|
||||||
|
}
|
||||||
|
|
||||||
|
func testEncodeNumber() {
|
||||||
|
let recipientIds = [ "+1011" ]
|
||||||
|
let actual = try! CDSBatchOperation.encodePhoneNumbers(recipientIds: recipientIds)
|
||||||
|
let expected: Data = Data(bytes: [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf3])
|
||||||
|
|
||||||
|
XCTAssertEqual(expected, actual)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testEncodeMultipleNumber() {
|
||||||
|
let recipientIds = [ "+1011", "+15551231234"]
|
||||||
|
let actual = try! CDSBatchOperation.encodePhoneNumbers(recipientIds: recipientIds)
|
||||||
|
let expected: Data = Data(bytes: [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf3,
|
||||||
|
0x00, 0x00, 0x00, 0x03, 0x9e, 0xec, 0xf5, 0x02])
|
||||||
|
|
||||||
|
XCTAssertEqual(expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,24 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "TSRequest.h"
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
|
||||||
|
|
||||||
@interface CDSAttestationRequest : TSRequest
|
|
||||||
|
|
||||||
@property (nonatomic, readonly) NSString *authToken;
|
|
||||||
@property (nonatomic, readonly) NSString *username;
|
|
||||||
|
|
||||||
- (instancetype)init NS_UNAVAILABLE;
|
|
||||||
|
|
||||||
- (TSRequest *)initWithURL:(NSURL *)URL
|
|
||||||
method:(NSString *)method
|
|
||||||
parameters:(nullable NSDictionary<NSString *, id> *)parameters
|
|
||||||
username:(NSString *)username
|
|
||||||
authToken:(NSString *)authToken;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "CDSAttestationRequest.h"
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
|
||||||
|
|
||||||
@implementation CDSAttestationRequest
|
|
||||||
|
|
||||||
- (TSRequest *)initWithURL:(NSURL *)URL
|
|
||||||
method:(NSString *)method
|
|
||||||
parameters:(nullable NSDictionary<NSString *, id> *)parameters
|
|
||||||
username:(NSString *)username
|
|
||||||
authToken:(NSString *)authToken
|
|
||||||
{
|
|
||||||
OWSAssert(authToken.length > 0);
|
|
||||||
|
|
||||||
if (self = [super initWithURL:URL method:method parameters:parameters]) {
|
|
||||||
_username = username;
|
|
||||||
_authToken = authToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
|
||||||
Loading…
Reference in New Issue