mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
345b693225
Added the unit tests for the ConvoInfoVolatile Added icons to the swipe actions Updated jobs to be able to be prioritised (and added priorities to the launch jobs to avoid some odd behaviours) Fixed some build issues resulting from merging Fixed an issue with the open group pubkey encoding Fixed an issue where an imageView could get it's image set on a background thread Fixed a bug where the swipe actions weren't getting theming applied when the theme changed Fixed a bug where scheduling code after the next db transaction completes couldn't be nested (resulting in code not running) Fixed a bug where the PagedDataObserver might not notify of unobserved changes if they reverted previous unobserved changes Fixed a couple of incorrect SQL ordering use cases (was overriding instead of appending ordering) Fixed an issue where the app would re-upload the avatar every launch (only affected this branch) Fixed an issue where the home screen wouldn't update group avatars when their profile data changed
82 lines
2.9 KiB
Swift
82 lines
2.9 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import Combine
|
|
import SessionSnodeKit
|
|
import SessionUtilitiesKit
|
|
|
|
@testable import SessionMessagingKit
|
|
|
|
// FIXME: Change 'OnionRequestAPIType' to have instance methods instead of static methods once everything is updated to use 'Dependencies'
|
|
class TestOnionRequestAPI: OnionRequestAPIType {
|
|
struct RequestData: Codable {
|
|
let urlString: String?
|
|
let httpMethod: String
|
|
let headers: [String: String]
|
|
let body: Data?
|
|
let destination: OnionRequestAPIDestination
|
|
|
|
var publicKey: String? {
|
|
switch destination {
|
|
case .snode: return nil
|
|
case .server(_, _, let x25519PublicKey, _, _): return x25519PublicKey
|
|
}
|
|
}
|
|
}
|
|
|
|
class ResponseInfo: ResponseInfoType {
|
|
let requestData: RequestData
|
|
let code: Int
|
|
let headers: [String: String]
|
|
|
|
init(requestData: RequestData, code: Int, headers: [String: String]) {
|
|
self.requestData = requestData
|
|
self.code = code
|
|
self.headers = headers
|
|
}
|
|
}
|
|
|
|
class var mockResponse: Data? { return nil }
|
|
|
|
static func sendOnionRequest(_ request: URLRequest, to server: String, with x25519PublicKey: String, timeout: TimeInterval) -> AnyPublisher<(ResponseInfoType, Data?), Error> {
|
|
let responseInfo: ResponseInfo = ResponseInfo(
|
|
requestData: RequestData(
|
|
urlString: request.url?.absoluteString,
|
|
httpMethod: (request.httpMethod ?? "GET"),
|
|
headers: (request.allHTTPHeaderFields ?? [:]),
|
|
body: request.httpBody,
|
|
destination: OnionRequestAPIDestination.server(
|
|
host: (request.url?.host ?? ""),
|
|
target: OnionRequestAPIVersion.v4.rawValue,
|
|
x25519PublicKey: x25519PublicKey,
|
|
scheme: request.url!.scheme,
|
|
port: request.url!.port.map { UInt16($0) }
|
|
)
|
|
),
|
|
code: 200,
|
|
headers: [:]
|
|
)
|
|
|
|
return Just((responseInfo, mockResponse))
|
|
.setFailureType(to: Error.self)
|
|
.eraseToAnyPublisher()
|
|
}
|
|
|
|
static func sendOnionRequest(_ payload: Data, to snode: Snode, timeout: TimeInterval) -> AnyPublisher<(ResponseInfoType, Data?), Error> {
|
|
let responseInfo: ResponseInfo = ResponseInfo(
|
|
requestData: RequestData(
|
|
urlString: "\(snode.address):\(snode.port)/onion_req/v2",
|
|
httpMethod: "POST",
|
|
headers: [:],
|
|
body: payload,
|
|
destination: OnionRequestAPIDestination.snode(snode)
|
|
),
|
|
code: 200,
|
|
headers: [:]
|
|
)
|
|
|
|
return Just((responseInfo, mockResponse))
|
|
.setFailureType(to: Error.self)
|
|
.eraseToAnyPublisher()
|
|
}
|
|
}
|