diff --git a/Tests/AuthenticationTests/APIKeyTests.swift b/Tests/AuthenticationTests/APIKeyTests.swift index 894baa164..58aecba29 100644 --- a/Tests/AuthenticationTests/APIKeyTests.swift +++ b/Tests/AuthenticationTests/APIKeyTests.swift @@ -12,33 +12,32 @@ // See the License for the specific language governing permissions and // limitations under the License. -import XCTest - @testable import Authentication import JWTKit +import Testing -final class APIKeyTests: XCTestCase { +@Suite struct APIKeyTests { - func test_verify() throws { + @Test func verify() throws { // Ensure verification rejects expired tokens let s = Signer(secretSigningKey: "secret") let token = try s.generateToken(for: "foo", expiringOn: .distantPast, contact: "bar", tier: .tier1) do { _ = try s.verifyToken(token) - XCTFail("Expected a JWTError.claimVerificationFailure to the thrown") + Issue.record("Expected a JWTError.claimVerificationFailure to the thrown") } catch let JWTError.claimVerificationFailure(name: name, reason: reason) { - XCTAssertEqual(name, "exp") - XCTAssertEqual(reason, "expired") + #expect(name == "exp") + #expect(reason == "expired") } } - func test_isAuthorized() throws { - XCTAssertTrue(APIKey.mock(tier: .internal).isAuthorized(for: .tier1)) - XCTAssertTrue(APIKey.mock(tier: .internal).isAuthorized(for: .tier2)) - XCTAssertTrue(APIKey.mock(tier: .tier1).isAuthorized(for: .tier1)) - XCTAssertFalse(APIKey.mock(tier: .tier1).isAuthorized(for: .tier2)) + @Test func isAuthorized() throws { + #expect(APIKey.mock(tier: .internal).isAuthorized(for: .tier1)) + #expect(APIKey.mock(tier: .internal).isAuthorized(for: .tier2)) + #expect(APIKey.mock(tier: .tier1).isAuthorized(for: .tier1)) + #expect(!APIKey.mock(tier: .tier1).isAuthorized(for: .tier2)) } } diff --git a/Tests/AuthenticationTests/SignerTests.swift b/Tests/AuthenticationTests/SignerTests.swift index 65ad25032..15f5a6592 100644 --- a/Tests/AuthenticationTests/SignerTests.swift +++ b/Tests/AuthenticationTests/SignerTests.swift @@ -12,33 +12,32 @@ // See the License for the specific language governing permissions and // limitations under the License. -import XCTest - @testable import Authentication import JWTKit +import Testing -final class SignerTests: XCTestCase { +@Suite struct SignerTests { - func test_generateToken_verifyToken() throws { + @Test func generateToken_verifyToken() throws { // Round trip test let s = Signer(secretSigningKey: "secret") let token = try s.generateToken(for: "foo", contact: "bar", tier: .tier1) - XCTAssertTrue(!token.isEmpty) + #expect(!token.isEmpty) let key = try s.verifyToken(token) - XCTAssertEqual(key.sub, .init(value: "foo")) - XCTAssertEqual(key.contact, "bar") - XCTAssertEqual(key.tier, .tier1) + #expect(key.sub == .init(value: "foo")) + #expect(key.contact == "bar") + #expect(key.tier == .tier1) } - func test_verifyToken_failure() throws { + @Test func verifyToken_failure() throws { // Ensure verification requires the correct secret let token = try Signer(secretSigningKey: "secret").generateToken(for: "foo", contact: "bar", tier: .tier1) let otherSigner = Signer(secretSigningKey: "other") do { _ = try otherSigner.verifyToken(token) - XCTFail("Expected a JWTError.signatureVerifictionFailed to the thrown") + Issue.record("Expected a JWTError.signatureVerifictionFailed to the thrown") } catch JWTError.signatureVerifictionFailed { } } diff --git a/Tests/AuthenticationTests/TierTests.swift b/Tests/AuthenticationTests/TierTests.swift index 0a36c8b18..d11bff553 100644 --- a/Tests/AuthenticationTests/TierTests.swift +++ b/Tests/AuthenticationTests/TierTests.swift @@ -12,21 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -import XCTest - @testable import Authentication +import Testing + -final class TierTests: XCTestCase { +@Suite struct TierTests { - func test_Comparable() throws { - XCTAssertTrue(Tier.tier1 < Tier.tier2) - XCTAssertTrue(Tier.tier2 < Tier.internal) + @Test func Comparable() throws { + #expect(Tier.tier1 < Tier.tier2) + #expect(Tier.tier2 < Tier.internal) - XCTAssertFalse(Tier.tier1 > Tier.tier2) + #expect(!(Tier.tier1 > Tier.tier2)) - XCTAssertTrue(Tier.tier1 <= Tier.tier1) - XCTAssertTrue(Tier.tier1 >= Tier.tier1) + #expect(Tier.tier1 <= Tier.tier1) + #expect(Tier.tier1 >= Tier.tier1) } } diff --git a/Tests/S3StoreTests/S3StoreTests.swift b/Tests/S3StoreTests/S3StoreTests.swift index 0c8fcacda..4f1a4042b 100644 --- a/Tests/S3StoreTests/S3StoreTests.swift +++ b/Tests/S3StoreTests/S3StoreTests.swift @@ -12,36 +12,36 @@ // See the License for the specific language governing permissions and // limitations under the License. -import XCTest - @testable import S3Store +import Testing + -final class S3StoreTests: XCTestCase { +@Suite struct S3StoreTests { - func test_Key_path() throws { + @Test func Key_path() throws { do { let key = S3Store.Key(bucket: "bucket", path: "foo/bar") - XCTAssertEqual(key.path, "foo/bar") + #expect(key.path == "foo/bar") } do { let key = S3Store.Key(bucket: "bucket", path: "/foo/bar") - XCTAssertEqual(key.path, "foo/bar") + #expect(key.path == "foo/bar") } do { let key = S3Store.Key(bucket: "bucket", path: "//foo/bar") - XCTAssertEqual(key.path, "foo/bar") + #expect(key.path == "foo/bar") } } - func test_Key_objectUrl() throws { + @Test func Key_objectUrl() throws { let key = S3Store.Key(bucket: "bucket", path: "foo/bar") - XCTAssertEqual(key.objectUrl, "https://bucket.s3.us-east-2.amazonaws.com/foo/bar") + #expect(key.objectUrl == "https://bucket.s3.us-east-2.amazonaws.com/foo/bar") } - func test_Key_s3Uri() throws { + @Test func Key_s3Uri() throws { let key = S3Store.Key(bucket: "bucket", path: "foo/bar") - XCTAssertEqual(key.s3Uri, "s3://bucket/foo/bar") + #expect(key.s3Uri == "s3://bucket/foo/bar") } }