From 89260519848f5c5f03e4d8ad2597285152fc4147 Mon Sep 17 00:00:00 2001 From: Francesco Paolo Severino Date: Wed, 25 Sep 2024 22:03:06 +0200 Subject: [PATCH] Add even more tests --- Tests/OrdersTests/OrdersTests.swift | 27 +++++++++++++++++++++++++++ Tests/PassesTests/PassesTests.swift | 27 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/Tests/OrdersTests/OrdersTests.swift b/Tests/OrdersTests/OrdersTests.swift index 0c13d35..7c1d058 100644 --- a/Tests/OrdersTests/OrdersTests.swift +++ b/Tests/OrdersTests/OrdersTests.swift @@ -145,6 +145,23 @@ final class OrdersTests: XCTestCase { let deviceLibraryIdentifier = "abcdefg" let pushToken = "1234567890" + try await app.test( + .GET, + "\(ordersURI)devices/\(deviceLibraryIdentifier)/registrations/\(order.orderTypeIdentifier)?ordersModifiedSince=0", + afterResponse: { res async throws in + XCTAssertEqual(res.status, .noContent) + } + ) + + try await app.test( + .DELETE, + "\(ordersURI)devices/\(deviceLibraryIdentifier)/registrations/\(order.orderTypeIdentifier)/\(order.requireID())", + headers: ["Authorization": "AppleOrder \(order.authenticationToken)"], + afterResponse: { res async throws in + XCTAssertEqual(res.status, .notFound) + } + ) + // Test registration without authentication token try await app.test( .POST, @@ -248,6 +265,16 @@ final class OrdersTests: XCTestCase { } ) + // Test call with invalid UUID + try await app.test( + .DELETE, + "\(ordersURI)devices/\(deviceLibraryIdentifier)/registrations/\(order.orderTypeIdentifier)/\("not-a-uuid")", + headers: ["Authorization": "AppleOrder \(order.authenticationToken)"], + afterResponse: { res async throws in + XCTAssertEqual(res.status, .badRequest) + } + ) + try await app.test( .DELETE, "\(ordersURI)devices/\(deviceLibraryIdentifier)/registrations/\(order.orderTypeIdentifier)/\(order.requireID())", diff --git a/Tests/PassesTests/PassesTests.swift b/Tests/PassesTests/PassesTests.swift index 280eaef..a9af438 100644 --- a/Tests/PassesTests/PassesTests.swift +++ b/Tests/PassesTests/PassesTests.swift @@ -283,6 +283,23 @@ final class PassesTests: XCTestCase { let deviceLibraryIdentifier = "abcdefg" let pushToken = "1234567890" + try await app.test( + .GET, + "\(passesURI)devices/\(deviceLibraryIdentifier)/registrations/\(pass.passTypeIdentifier)?passesUpdatedSince=0", + afterResponse: { res async throws in + XCTAssertEqual(res.status, .noContent) + } + ) + + try await app.test( + .DELETE, + "\(passesURI)devices/\(deviceLibraryIdentifier)/registrations/\(pass.passTypeIdentifier)/\(pass.requireID())", + headers: ["Authorization": "ApplePass \(pass.authenticationToken)"], + afterResponse: { res async throws in + XCTAssertEqual(res.status, .notFound) + } + ) + // Test registration without authentication token try await app.test( .POST, @@ -386,6 +403,16 @@ final class PassesTests: XCTestCase { } ) + // Test call with invalid UUID + try await app.test( + .DELETE, + "\(passesURI)devices/\(deviceLibraryIdentifier)/registrations/\(pass.passTypeIdentifier)/\("not-a-uuid")", + headers: ["Authorization": "ApplePass \(pass.authenticationToken)"], + afterResponse: { res async throws in + XCTAssertEqual(res.status, .badRequest) + } + ) + try await app.test( .DELETE, "\(passesURI)devices/\(deviceLibraryIdentifier)/registrations/\(pass.passTypeIdentifier)/\(pass.requireID())",