|
| 1 | +// Copyright 2023 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +import Foundation |
| 16 | +import XCTest |
| 17 | + |
| 18 | +@testable import FirebaseAuth |
| 19 | + |
| 20 | +class AuthAppCredentialTests: XCTestCase { |
| 21 | + private let kReceipt = "RECEIPT" |
| 22 | + private let kSecret = "SECRET" |
| 23 | + |
| 24 | + /** @fn testInitializer |
| 25 | + @brief Tests the initializer of the class. |
| 26 | + */ |
| 27 | + func testInitializer() { |
| 28 | + let credential = AuthAppCredential(receipt: kReceipt, secret: kSecret) |
| 29 | + XCTAssertEqual(credential.receipt, kReceipt) |
| 30 | + XCTAssertEqual(credential.secret, kSecret) |
| 31 | + } |
| 32 | + |
| 33 | + /** @fn testSecureCoding |
| 34 | + @brief Tests the implementation of NSSecureCoding protocol. |
| 35 | + */ |
| 36 | + func testSecureCoding() throws { |
| 37 | + let credential = AuthAppCredential(receipt: kReceipt, secret: kSecret) |
| 38 | + let data = try NSKeyedArchiver.archivedData( |
| 39 | + withRootObject: credential, |
| 40 | + requiringSecureCoding: true |
| 41 | + ) |
| 42 | + let otherCredential = NSKeyedUnarchiver.unarchiveObject(with: data) as? AuthAppCredential |
| 43 | + XCTAssertEqual(otherCredential?.receipt, kReceipt) |
| 44 | + XCTAssertEqual(otherCredential?.secret, kSecret) |
| 45 | + } |
| 46 | +} |
0 commit comments