Skip to content

Commit 4ebf7bd

Browse files
authored
[auth-swift] AuthAppCredentialTests.swift (#11336)
1 parent a6a7c4c commit 4ebf7bd

File tree

3 files changed

+48
-69
lines changed

3 files changed

+48
-69
lines changed

FirebaseAuth/Sources/Swift/SystemService/AuthAppCredential.swift

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ private let kReceiptKey = "receipt"
2424
*/
2525
private let kSecretKey = "secret"
2626

27+
// TODO: Remove objc public after Sample app is replaced.
28+
2729
/** @class FIRAuthAppCredential
2830
@brief A class represents a credential that proves the identity of the app.
2931
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
}

FirebaseAuth/Tests/UnitObjC/FIRAuthAppCredentialTests.m

-69
This file was deleted.

0 commit comments

Comments
 (0)