mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
This paves the way to add a second set of paths with a separate server URL to be able to shed requests to offerings and product entitlement mapping to a separate server. ### Changes: - New `HTTPRequestPath` with the same properties as `HTTPRequest.Path` + a new `serverHostURL` - Moved proxy logic from `SystemInfo`/`HTTPClient` to `HTTPRequestPath` - Simplified `HTTPRequest` implementation
59 lines
1.6 KiB
Swift
59 lines
1.6 KiB
Swift
//
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// BackendSignatureVerificationTests.swift
|
|
//
|
|
// Created by Nacho Soto on 3/7/22.
|
|
|
|
import Foundation
|
|
import Nimble
|
|
import XCTest
|
|
|
|
@testable import RevenueCat
|
|
|
|
class BackendSignatureVerificationTests: BaseBackendTests {
|
|
|
|
override var verificationMode: Configuration.EntitlementVerificationMode {
|
|
return .informational
|
|
}
|
|
|
|
override func createClient() -> MockHTTPClient {
|
|
super.createClient(#file)
|
|
}
|
|
|
|
func testRequestContainsSignatureHeader() throws {
|
|
self.httpClient.mock(
|
|
requestPath: .health,
|
|
response: .init(statusCode: .success, verificationResult: .verified)
|
|
)
|
|
|
|
let error = waitUntilValue { completed in
|
|
self.internalAPI.healthRequest(signatureVerification: true, completion: completed)
|
|
}
|
|
|
|
expect(error).to(beNil())
|
|
}
|
|
|
|
func testRequestFailsIfSignatureVerificationFails() throws {
|
|
let expectedError: NetworkError = .signatureVerificationFailed(path: HTTPRequest.Path.health, code: .success)
|
|
|
|
self.httpClient.mock(
|
|
requestPath: .health,
|
|
response: .init(error: expectedError)
|
|
)
|
|
|
|
let error = waitUntilValue { completed in
|
|
self.internalAPI.healthRequest(signatureVerification: true, completion: completed)
|
|
}
|
|
|
|
expect(error).to(matchError(BackendError.networkError(expectedError)))
|
|
}
|
|
|
|
}
|