diff --git a/Package.swift b/Package.swift index 7a83b5d6b..688f38a60 100644 --- a/Package.swift +++ b/Package.swift @@ -42,7 +42,7 @@ let package = Package( ], path: "Tests/CoreAPITests", resources: [ - // .process("Stubs") // Relative to path + .process("Stubs") // Relative to path ] ), ] diff --git a/Sources/CoreAPI/WordPressComRestApiErrorDomain.swift b/Sources/CoreAPI/WordPressComRestApiErrorDomain.swift new file mode 100644 index 000000000..0395f4390 --- /dev/null +++ b/Sources/CoreAPI/WordPressComRestApiErrorDomain.swift @@ -0,0 +1,30 @@ +import Foundation + +/// Error domain of `NSError` instances that are converted from `WordPressComRestApiEndpointError` +/// and `WordPressAPIError` instances. +/// +/// See `extension WordPressComRestApiEndpointError: CustomNSError` for context. +let WordPressComRestApiErrorDomain = "WordPressKit.WordPressComRestApiError" + +// WordPressComRestApiErrorDomain is accessible only in Swift and, since it's a global, cannot be made @objc. +// As a workaround, here is a builder to init NSError with that domain and a method to check the domain. +@objc +public extension NSError { + + @objc + static func wordPressComRestApiError( + code: Int, + userInfo: [String: Any]? + ) -> NSError { + NSError( + domain: WordPressComRestApiErrorDomain, + code: code, + userInfo: userInfo + ) + } + + @objc + func hasWordPressComRestApiErrorDomain() -> Bool { + domain == WordPressComRestApiErrorDomain + } +} diff --git a/Sources/WordPressKit/Services/MediaServiceRemoteREST.m b/Sources/WordPressKit/Services/MediaServiceRemoteREST.m index 6aca3d445..86f6babef 100644 --- a/Sources/WordPressKit/Services/MediaServiceRemoteREST.m +++ b/Sources/WordPressKit/Services/MediaServiceRemoteREST.m @@ -244,7 +244,8 @@ - (NSError *)processMediaUploadErrors:(NSArray *)errorList { errorMessage = errorInfo[@"message"]; } NSDictionary *errorDictionary = @{NSLocalizedDescriptionKey: errorMessage}; - error = [NSError errorWithDomain:WordPressComRestApiErrorDomain code:WordPressComRestApiErrorCodeUploadFailed userInfo:errorDictionary]; + error = [NSError wordPressComRestApiErrorWithCode:WordPressComRestApiErrorCodeUploadFailed + userInfo:errorDictionary]; } return error; } @@ -296,9 +297,8 @@ - (void)deleteMedia:(RemoteMedia *)media } } else { if (failure) { - NSError *error = [NSError errorWithDomain:WordPressComRestApiErrorDomain - code:WordPressComRestApiErrorCodeUnknown - userInfo:nil]; + NSError *error = [NSError wordPressComRestApiErrorWithCode:WordPressComRestApiErrorCodeUnknown + userInfo:nil]; failure(error); } } @@ -369,9 +369,8 @@ -(void)getVideoPressToken:(NSString *)videoPressID } } else { if (failure) { - NSError *error = [NSError errorWithDomain:WordPressComRestApiErrorDomain - code:WordPressComRestApiErrorCodeUnknown - userInfo:nil]; + NSError *error = [NSError wordPressComRestApiErrorWithCode:WordPressComRestApiErrorCodeUnknown + userInfo:nil]; failure(error); } } diff --git a/Sources/WordPressKit/Services/WordPressComServiceRemote.m b/Sources/WordPressKit/Services/WordPressComServiceRemote.m index 20cf3a879..adaf86e19 100644 --- a/Sources/WordPressKit/Services/WordPressComServiceRemote.m +++ b/Sources/WordPressKit/Services/WordPressComServiceRemote.m @@ -179,10 +179,9 @@ - (void)createWPComBlogWithUrl:(NSString *)blogUrl NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init]; userInfo[WordPressComRestApi.ErrorKeyErrorMessage] = localizedErrorMessage; userInfo[NSLocalizedDescriptionKey] = localizedErrorMessage; - NSError *errorWithLocalizedMessage = [[NSError alloc] initWithDomain:WordPressComRestApiErrorDomain - code:WordPressComRestApiErrorCodeUnknown - userInfo:userInfo]; - + NSError *errorWithLocalizedMessage = [NSError wordPressComRestApiErrorWithCode:WordPressComRestApiErrorCodeUnknown + userInfo:userInfo]; + failure(errorWithLocalizedMessage); } else { success(responseObject); @@ -229,7 +228,7 @@ - (void)createWPComBlogWithUrl:(NSString *)blogUrl - (NSError *)errorWithLocalizedMessage:(NSError *)error { NSError *errorWithLocalizedMessage = error; - if ([error.domain isEqualToString:WordPressComRestApiErrorDomain] && + if ([error hasWordPressComRestApiErrorDomain] && [error.userInfo objectForKey:WordPressComRestApi.ErrorKeyErrorCode] != nil) { NSString *localizedErrorMessage = [self errorMessageForError:error]; diff --git a/Sources/WordPressKit/Utility/Constants.h b/Sources/WordPressKit/Utility/Constants.h deleted file mode 100644 index 92d103659..000000000 --- a/Sources/WordPressKit/Utility/Constants.h +++ /dev/null @@ -1,7 +0,0 @@ -#import - -NS_ASSUME_NONNULL_BEGIN - -FOUNDATION_EXTERN NSString *WordPressComRestApiErrorDomain; - -NS_ASSUME_NONNULL_END diff --git a/Sources/WordPressKit/Utility/Constants.m b/Sources/WordPressKit/Utility/Constants.m deleted file mode 100644 index 87c8320f4..000000000 --- a/Sources/WordPressKit/Utility/Constants.m +++ /dev/null @@ -1,7 +0,0 @@ -#import "Constants.h" - -/// Error domain of `NSError` instances that are converted from `WordPressComRestApiEndpointError` -/// and `WordPressAPIError` instances. -/// -/// See `extension WordPressComRestApiEndpointError: CustomNSError` for context. -NSString *WordPressComRestApiErrorDomain = @"WordPressKit.WordPressComRestApiError"; diff --git a/Sources/WordPressKit/Utility/HTTPProtocolHelpers.swift b/Sources/WordPressKit/Utility/HTTPProtocolHelpers.swift index b21feda1e..b446e31d8 100644 --- a/Sources/WordPressKit/Utility/HTTPProtocolHelpers.swift +++ b/Sources/WordPressKit/Utility/HTTPProtocolHelpers.swift @@ -1,48 +1,5 @@ import Foundation -extension String.Encoding { - /// See: https://www.iana.org/assignments/character-sets/character-sets.xhtml - init?(ianaCharsetName: String) { - let encoding: CFStringEncoding = CFStringConvertIANACharSetNameToEncoding(ianaCharsetName as CFString) - guard encoding != kCFStringEncodingInvalidId, - let builtInEncoding = CFStringBuiltInEncodings(rawValue: encoding) - else { - return nil - } - - switch builtInEncoding { - case .macRoman: - self = .macOSRoman - case .windowsLatin1: - self = .windowsCP1252 - case .isoLatin1: - self = .isoLatin1 - case .nextStepLatin: - self = .nextstep - case .ASCII: - self = .ascii - case .unicode: - self = .unicode - case .UTF8: - self = .utf8 - case .nonLossyASCII: - self = .nonLossyASCII - case .UTF16BE: - self = .utf16BigEndian - case .UTF16LE: - self = .utf16LittleEndian - case .UTF32: - self = .utf32 - case .UTF32BE: - self = .utf32BigEndian - case .UTF32LE: - self = .utf32LittleEndian - @unknown default: - return nil - } - } -} - extension HTTPURLResponse { /// Return parameter value in a header field. diff --git a/Sources/WordPressKit/WordPressKit.h b/Sources/WordPressKit/WordPressKit.h index 395134db1..3e8795849 100644 --- a/Sources/WordPressKit/WordPressKit.h +++ b/Sources/WordPressKit/WordPressKit.h @@ -53,4 +53,3 @@ FOUNDATION_EXPORT const unsigned char WordPressKitVersionString[]; #import #import -#import diff --git a/Tests/WordPressKitTests/Tests/Utilities/AppTransportSecuritySettingsTests.swift b/Tests/CoreAPITests/AppTransportSecuritySettingsTests.swift similarity index 98% rename from Tests/WordPressKitTests/Tests/Utilities/AppTransportSecuritySettingsTests.swift rename to Tests/CoreAPITests/AppTransportSecuritySettingsTests.swift index 513596b8e..0fd612fcc 100644 --- a/Tests/WordPressKitTests/Tests/Utilities/AppTransportSecuritySettingsTests.swift +++ b/Tests/CoreAPITests/AppTransportSecuritySettingsTests.swift @@ -1,5 +1,9 @@ import XCTest +#if SWIFT_PACKAGE +@testable import CoreAPI +#else @testable import WordPressKit +#endif final class AppTransportSecuritySettingsTests: XCTestCase { diff --git a/Tests/WordPressKitTests/Fakes/FakeInfoDictionaryObjectProvider.swift b/Tests/CoreAPITests/FakeInfoDictionaryObjectProvider.swift similarity index 88% rename from Tests/WordPressKitTests/Fakes/FakeInfoDictionaryObjectProvider.swift rename to Tests/CoreAPITests/FakeInfoDictionaryObjectProvider.swift index 405922f78..74569e5bf 100644 --- a/Tests/WordPressKitTests/Fakes/FakeInfoDictionaryObjectProvider.swift +++ b/Tests/CoreAPITests/FakeInfoDictionaryObjectProvider.swift @@ -1,5 +1,8 @@ -import Foundation +#if SWIFT_PACKAGE +@testable import CoreAPI +#else @testable import WordPressKit +#endif class FakeInfoDictionaryObjectProvider: InfoDictionaryObjectProvider { private let appTransportSecurity: [String: Any]? diff --git a/Tests/WordPressKitTests/Tests/Utilities/HTTPRequestBuilderTests.swift b/Tests/CoreAPITests/HTTPRequestBuilderTests.swift similarity index 98% rename from Tests/WordPressKitTests/Tests/Utilities/HTTPRequestBuilderTests.swift rename to Tests/CoreAPITests/HTTPRequestBuilderTests.swift index 12824e66a..4b455c76c 100644 --- a/Tests/WordPressKitTests/Tests/Utilities/HTTPRequestBuilderTests.swift +++ b/Tests/CoreAPITests/HTTPRequestBuilderTests.swift @@ -1,8 +1,10 @@ -import Foundation -import XCTest -import wpxmlrpc - +#if SWIFT_PACKAGE +@testable import CoreAPI +#else @testable import WordPressKit +#endif +import wpxmlrpc +import XCTest class HTTPRequestBuilderTests: XCTestCase { @@ -413,7 +415,7 @@ class HTTPRequestBuilderTests: XCTestCase { } func testXMLRPCUpload() throws { - let file = try XCTUnwrap(Bundle(for: type(of: self)).url(forResource: "me-settings-success", withExtension: "json")) + let file = try XCTUnwrap(Bundle.coreAPITestsBundle.url(forResource: "me-settings-success", withExtension: "json")) let fileContentBase64 = try Data(contentsOf: file).base64EncodedString() let fileStream = try XCTUnwrap(InputStream(url: file)) let request = try HTTPRequestBuilder(url: URL(string: "https://w.org/xmlrpc.php")!) diff --git a/Tests/WordPressKitTests/Tests/Utilities/MultipartFormTests.swift b/Tests/CoreAPITests/MultipartFormTests.swift similarity index 99% rename from Tests/WordPressKitTests/Tests/Utilities/MultipartFormTests.swift rename to Tests/CoreAPITests/MultipartFormTests.swift index f675261cf..c966ff9db 100644 --- a/Tests/WordPressKitTests/Tests/Utilities/MultipartFormTests.swift +++ b/Tests/CoreAPITests/MultipartFormTests.swift @@ -2,8 +2,11 @@ import Foundation import Alamofire import XCTest import CryptoKit - +#if SWIFT_PACKAGE +@testable import CoreAPI +#else @testable import WordPressKit +#endif class MutliparFormDataTests: XCTestCase { struct Form: Codable { diff --git a/Tests/WordPressKitTests/Tests/WordPressAPI/NonceRetrievalTests.swift b/Tests/CoreAPITests/NonceRetrievalTests.swift similarity index 97% rename from Tests/WordPressKitTests/Tests/WordPressAPI/NonceRetrievalTests.swift rename to Tests/CoreAPITests/NonceRetrievalTests.swift index 811dad8a2..c27c8cd1d 100644 --- a/Tests/WordPressKitTests/Tests/WordPressAPI/NonceRetrievalTests.swift +++ b/Tests/CoreAPITests/NonceRetrievalTests.swift @@ -1,8 +1,12 @@ import Foundation import XCTest import OHHTTPStubs - +#if SWIFT_PACKAGE +@testable import CoreAPI +import OHHTTPStubsSwift +#else @testable import WordPressKit +#endif class NonceRetrievalTests: XCTestCase { diff --git a/Tests/WordPressKitTests/Tests/Utilities/RSDParserTests.swift b/Tests/CoreAPITests/RSDParserTests.swift similarity index 97% rename from Tests/WordPressKitTests/Tests/Utilities/RSDParserTests.swift rename to Tests/CoreAPITests/RSDParserTests.swift index d73a3df85..700c283ac 100644 --- a/Tests/WordPressKitTests/Tests/Utilities/RSDParserTests.swift +++ b/Tests/CoreAPITests/RSDParserTests.swift @@ -1,7 +1,10 @@ import Foundation import XCTest - +#if SWIFT_PACKAGE +@testable import CoreAPI +#else @testable import WordPressKit +#endif class RSDParserTests: XCTestCase { diff --git a/Tests/WordPressKitTests/Mock Data/xmlrpc-response-invalid.html b/Tests/CoreAPITests/Stubs/HTML/xmlrpc-response-invalid.html similarity index 100% rename from Tests/WordPressKitTests/Mock Data/xmlrpc-response-invalid.html rename to Tests/CoreAPITests/Stubs/HTML/xmlrpc-response-invalid.html diff --git a/Tests/WordPressKitTests/Mock Data/xmlrpc-response-mobile-plugin-redirect.html b/Tests/CoreAPITests/Stubs/HTML/xmlrpc-response-mobile-plugin-redirect.html similarity index 100% rename from Tests/WordPressKitTests/Mock Data/xmlrpc-response-mobile-plugin-redirect.html rename to Tests/CoreAPITests/Stubs/HTML/xmlrpc-response-mobile-plugin-redirect.html diff --git a/Tests/WordPressKitTests/Tests/Utilities/HTTPRequestHelpers.swift b/Tests/CoreAPITests/URLRequest+HTTPBodyText.swift similarity index 100% rename from Tests/WordPressKitTests/Tests/Utilities/HTTPRequestHelpers.swift rename to Tests/CoreAPITests/URLRequest+HTTPBodyText.swift diff --git a/Tests/WordPressKitTests/Tests/WordPressComOAuthClientTests.swift b/Tests/CoreAPITests/WordPressComOAuthClientTests.swift similarity index 92% rename from Tests/WordPressKitTests/Tests/WordPressComOAuthClientTests.swift rename to Tests/CoreAPITests/WordPressComOAuthClientTests.swift index 49bfff09e..37e1c0af2 100644 --- a/Tests/WordPressKitTests/Tests/WordPressComOAuthClientTests.swift +++ b/Tests/CoreAPITests/WordPressComOAuthClientTests.swift @@ -1,8 +1,12 @@ import Foundation import XCTest import OHHTTPStubs - +#if SWIFT_PACKAGE +@testable import CoreAPI +import OHHTTPStubsSwift +#else @testable import WordPressKit +#endif class WordPressComOAuthClientTests: XCTestCase { @@ -27,7 +31,7 @@ class WordPressComOAuthClientTests: XCTestCase { } func testAuthenticateUsernameNo2FASuccessCase() throws { - let stubPath = try XCTUnwrap(OHPathForFile("WordPressComOAuthSuccess.json", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("WordPressComOAuthSuccess.json", Bundle.coreAPITestsBundle)) stub(condition: isOauthTokenRequest(url: .oAuthTokenUrl)) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) } @@ -53,7 +57,7 @@ class WordPressComOAuthClientTests: XCTestCase { } func testAuthenticateUsernameNo2FASuccessCase_withMFAClosure() throws { - let stubPath = try XCTUnwrap(OHPathForFile("WordPressComOAuthSuccess.json", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("WordPressComOAuthSuccess.json", Bundle.coreAPITestsBundle)) stub(condition: isOauthTokenRequest(url: .oAuthTokenUrl)) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) } @@ -83,7 +87,7 @@ class WordPressComOAuthClientTests: XCTestCase { func testAuthenticateUsernameNo2FAFailureWrongPasswordCase() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComOAuthWrongPasswordFail.json", type(of: self)) + OHPathForFileInBundle("WordPressComOAuthWrongPasswordFail.json", Bundle.coreAPITestsBundle) ) stub(condition: isOauthTokenRequest(url: .oAuthTokenUrl)) { _ in return fixture(filePath: stubPath, status: 400, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -110,7 +114,7 @@ class WordPressComOAuthClientTests: XCTestCase { func testAuthenticateUsernameNo2FAFailureWrongPasswordCase_withMFAClosure() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComOAuthWrongPasswordFail.json", type(of: self)) + OHPathForFileInBundle("WordPressComOAuthWrongPasswordFail.json", Bundle.coreAPITestsBundle) ) stub(condition: isOauthTokenRequest(url: .oAuthTokenUrl)) { _ in return fixture(filePath: stubPath, status: 400, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -140,7 +144,7 @@ class WordPressComOAuthClientTests: XCTestCase { func testAuthenticateUsername2FAWrong2FACase() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComOAuthNeeds2FAFail.json", type(of: self)) + OHPathForFileInBundle("WordPressComOAuthNeeds2FAFail.json", Bundle.coreAPITestsBundle) ) stub(condition: isOauthTokenRequest(url: .oAuthTokenUrl)) { _ in return fixture( @@ -191,7 +195,7 @@ class WordPressComOAuthClientTests: XCTestCase { func testAuthenticateUsername2FAWrong2FACase_withMFAClosure() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComOAuthNeeds2FAFail.json", type(of: self)) + OHPathForFileInBundle("WordPressComOAuthNeeds2FAFail.json", Bundle.coreAPITestsBundle) ) stub(condition: isOauthTokenRequest(url: .oAuthTokenUrl)) { _ in return fixture( @@ -245,7 +249,7 @@ class WordPressComOAuthClientTests: XCTestCase { func testAuthenticateUsernameRequiresWebauthnMultifactorAuthentication() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComOAuthNeedsWebauthnMFA.json", type(of: self)) + OHPathForFileInBundle("WordPressComOAuthNeedsWebauthnMFA.json", Bundle.coreAPITestsBundle) ) stub(condition: isOauthTokenRequest(url: .oAuthTokenUrl)) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -276,7 +280,7 @@ class WordPressComOAuthClientTests: XCTestCase { func testRequestOneTimeCodeWithUsername() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComOAuthNeeds2FAFail.json", type(of: self)) + OHPathForFileInBundle("WordPressComOAuthNeeds2FAFail.json", Bundle.coreAPITestsBundle) ) stub(condition: isOauthTokenRequest(url: .oAuthTokenUrl)) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -297,7 +301,7 @@ class WordPressComOAuthClientTests: XCTestCase { func testRequestSocial2FACodeWithUserID() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComSocial2FACodeSuccess.json", type(of: self)) + OHPathForFileInBundle("WordPressComSocial2FACodeSuccess.json", Bundle.coreAPITestsBundle) ) stub(condition: isOauthTokenRequest(url: .socialLoginNewSMS2FA)) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -320,7 +324,7 @@ class WordPressComOAuthClientTests: XCTestCase { func testAuthenticateWithIDToken() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComAuthenticateWithIDTokenBearerTokenSuccess.json", type(of: self)) + OHPathForFileInBundle("WordPressComAuthenticateWithIDTokenBearerTokenSuccess.json", Bundle.coreAPITestsBundle) ) stub(condition: isOauthTokenRequest(url: .socialLogin)) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -355,7 +359,7 @@ class WordPressComOAuthClientTests: XCTestCase { func testAuthenticateWithIDToken2FANeeded() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComAuthenticateWithIDToken2FANeededSuccess.json", type(of: self)) + OHPathForFileInBundle("WordPressComAuthenticateWithIDToken2FANeededSuccess.json", Bundle.coreAPITestsBundle) ) stub(condition: isOauthTokenRequest(url: .socialLogin)) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -391,7 +395,7 @@ class WordPressComOAuthClientTests: XCTestCase { func testAuthenticateWithIDTokenUserNeedsConnection() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComAuthenticateWithIDTokenExistingUserNeedsConnection.json", type(of: self)) + OHPathForFileInBundle("WordPressComAuthenticateWithIDTokenExistingUserNeedsConnection.json", Bundle.coreAPITestsBundle) ) stub(condition: isOauthTokenRequest(url: .socialLogin)) { _ in return fixture(filePath: stubPath, status: 400, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -425,7 +429,7 @@ class WordPressComOAuthClientTests: XCTestCase { func testAuthenticateSocialLoginUser() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComAuthenticateWithIDTokenBearerTokenSuccess.json", type(of: self)) + OHPathForFileInBundle("WordPressComAuthenticateWithIDTokenBearerTokenSuccess.json", Bundle.coreAPITestsBundle) ) stub(condition: isOauthTokenRequest(url: .socialLogin2FA)) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -448,7 +452,7 @@ class WordPressComOAuthClientTests: XCTestCase { func testRequestWebauthnChallengeReturnsCompleteChallengeInfo() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComOAuthRequestChallenge.json", type(of: self)) + OHPathForFileInBundle("WordPressComOAuthRequestChallenge.json", Bundle.coreAPITestsBundle) ) stub(condition: isOauthTokenRequest(url: .requestWebauthnChallenge)) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -471,7 +475,7 @@ class WordPressComOAuthClientTests: XCTestCase { func testAuthenticateWebauthSignatureReturnsOauthToken() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComOAuthAuthenticateSignature.json", type(of: self)) + OHPathForFileInBundle("WordPressComOAuthAuthenticateSignature.json", Bundle.coreAPITestsBundle) ) stub(condition: isOauthTokenRequest(url: .verifySignature)) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) diff --git a/Tests/WordPressKitTests/Tests/WordPressComRestApiTests+Error.swift b/Tests/CoreAPITests/WordPressComRestApiTests+Error.swift similarity index 92% rename from Tests/WordPressKitTests/Tests/WordPressComRestApiTests+Error.swift rename to Tests/CoreAPITests/WordPressComRestApiTests+Error.swift index b8d3a58b1..a34c69cef 100644 --- a/Tests/WordPressKitTests/Tests/WordPressComRestApiTests+Error.swift +++ b/Tests/CoreAPITests/WordPressComRestApiTests+Error.swift @@ -1,7 +1,9 @@ -import Foundation import XCTest - +#if SWIFT_PACKAGE +@testable import CoreAPI +#else @testable import WordPressKit +#endif class WordPressComRestApiErrorTests: XCTestCase { diff --git a/Tests/WordPressKitTests/Tests/WordPressComRestApiTests+Locale.swift b/Tests/CoreAPITests/WordPressComRestApiTests+Locale.swift similarity index 97% rename from Tests/WordPressKitTests/Tests/WordPressComRestApiTests+Locale.swift rename to Tests/CoreAPITests/WordPressComRestApiTests+Locale.swift index 2c5aa658c..0435003a5 100644 --- a/Tests/WordPressKitTests/Tests/WordPressComRestApiTests+Locale.swift +++ b/Tests/CoreAPITests/WordPressComRestApiTests+Locale.swift @@ -1,9 +1,12 @@ -import Foundation import XCTest import OHHTTPStubs - import WordPressShared +#if SWIFT_PACKAGE +@testable import CoreAPI +import OHHTTPStubsSwift +#else @testable import WordPressKit +#endif extension WordPressComRestApiTests { diff --git a/Tests/WordPressKitTests/Tests/WordPressComRestApiTests.swift b/Tests/CoreAPITests/WordPressComRestApiTests.swift similarity index 93% rename from Tests/WordPressKitTests/Tests/WordPressComRestApiTests.swift rename to Tests/CoreAPITests/WordPressComRestApiTests.swift index 611b4298b..a7f65b69c 100644 --- a/Tests/WordPressKitTests/Tests/WordPressComRestApiTests.swift +++ b/Tests/CoreAPITests/WordPressComRestApiTests.swift @@ -1,8 +1,13 @@ -import Foundation import XCTest import OHHTTPStubs import WordPressShared +#if SWIFT_PACKAGE +import APIInterface +@testable import CoreAPI +import OHHTTPStubsSwift +#else @testable import WordPressKit +#endif class WordPressComRestApiTests: XCTestCase { @@ -113,7 +118,7 @@ class WordPressComRestApiTests: XCTestCase { func testSuccessfullCall() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComRestApiMedia.json", type(of: self)) + OHPathForFileInBundle("WordPressComRestApiMedia.json", Bundle.coreAPITestsBundle) ) stub(condition: isRestAPIRequest()) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -170,7 +175,7 @@ class WordPressComRestApiTests: XCTestCase { func testInvalidTokenFailedCall() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComRestApiFailRequestInvalidToken.json", type(of: self)) + OHPathForFileInBundle("WordPressComRestApiFailRequestInvalidToken.json", Bundle.coreAPITestsBundle) ) stub(condition: isRestAPIRequest()) { _ in return fixture(filePath: stubPath, status: 400, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -191,7 +196,7 @@ class WordPressComRestApiTests: XCTestCase { func testInvalidJSONReceivedFailedCall() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComRestApiFailInvalidJSON.json", type(of: self)) + OHPathForFileInBundle("WordPressComRestApiFailInvalidJSON.json", Bundle.coreAPITestsBundle) ) stub(condition: isRestAPIRequest()) { _ in return fixture(filePath: stubPath, status: 200, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -211,7 +216,7 @@ class WordPressComRestApiTests: XCTestCase { func testInvalidJSONSentFailedCall() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComRestApiFailInvalidInput.json", type(of: self)) + OHPathForFileInBundle("WordPressComRestApiFailInvalidInput.json", Bundle.coreAPITestsBundle) ) stub(condition: isRestAPIMediaNewRequest()) { _ in return fixture(filePath: stubPath, status: 400, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -231,7 +236,7 @@ class WordPressComRestApiTests: XCTestCase { func testUnauthorizedFailedCall() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComRestApiFailUnauthorized.json", type(of: self)) + OHPathForFileInBundle("WordPressComRestApiFailUnauthorized.json", Bundle.coreAPITestsBundle) ) stub(condition: isRestAPIMediaNewRequest()) { _ in return fixture(filePath: stubPath, status: 403, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -250,7 +255,7 @@ class WordPressComRestApiTests: XCTestCase { } func testMultipleErrorsFailedCall() throws { - let stubPath = try XCTUnwrap(OHPathForFile("WordPressComRestApiMultipleErrors.json", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("WordPressComRestApiMultipleErrors.json", Bundle.coreAPITestsBundle)) stub(condition: isRestAPIMediaNewRequest()) { _ in return fixture(filePath: stubPath, status: 403, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) } @@ -269,7 +274,7 @@ class WordPressComRestApiTests: XCTestCase { func testMultipleErrorsFailedMultiPartPostCall() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComRestApiMultipleErrors.json", type(of: self)) + OHPathForFileInBundle("WordPressComRestApiMultipleErrors.json", Bundle.coreAPITestsBundle) ) stub(condition: isRestAPIMediaNewRequest()) { _ in return fixture(filePath: stubPath, status: 403, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -288,7 +293,7 @@ class WordPressComRestApiTests: XCTestCase { } func testStreamMethodCallWithInvalidFile() throws { - let stubPath = try XCTUnwrap(OHPathForFile("WordPressComRestApiMedia.json", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("WordPressComRestApiMedia.json", Bundle.coreAPITestsBundle)) stub(condition: isRestAPIMediaNewRequest()) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) } @@ -307,12 +312,12 @@ class WordPressComRestApiTests: XCTestCase { } func testStreamMethodParallelCalls() throws { - let stubPath = try XCTUnwrap(OHPathForFile("WordPressComRestApiMedia.json", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("WordPressComRestApiMedia.json", Bundle.coreAPITestsBundle)) stub(condition: isRestAPIMediaNewRequest()) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) } guard - let mediaPath = OHPathForFile("test-image.jpg", type(of: self)) + let mediaPath = OHPathForFileInBundle("test-image.jpg", Bundle.coreAPITestsBundle) else { return } @@ -357,7 +362,7 @@ class WordPressComRestApiTests: XCTestCase { } func testSuccessfullCallCommonGETStructure() throws { - let stubPath = try XCTUnwrap(OHPathForFile("WordPressComRestApiMedia.json", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("WordPressComRestApiMedia.json", Bundle.coreAPITestsBundle)) stub(condition: isRestAPIRequest()) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) } @@ -377,7 +382,7 @@ class WordPressComRestApiTests: XCTestCase { func testFailureCallCommonGETStructure() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComRestApiFailInvalidJSON.json", type(of: self)) + OHPathForFileInBundle("WordPressComRestApiFailInvalidJSON.json", Bundle.coreAPITestsBundle) ) stub(condition: isRestAPIRequest()) { _ in return fixture(filePath: stubPath, status: 200, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) @@ -447,7 +452,7 @@ class WordPressComRestApiTests: XCTestCase { func testTooManyRequestError() throws { let stubPath = try XCTUnwrap( - OHPathForFile("WordPressComRestApiFailThrottled.json", type(of: self)) + OHPathForFileInBundle("WordPressComRestApiFailThrottled.json", Bundle.coreAPITestsBundle) ) stub(condition: isAbsoluteURLString("https://public-api.wordpress.com/rest/v1/foo?locale=en")) { _ in return fixture(filePath: stubPath, status: 500, headers: ["Content-Type" as NSObject: "application/html" as AnyObject]) diff --git a/Tests/WordPressKitTests/Tests/WordPressAPI/WordPressOrgAPITests.swift b/Tests/CoreAPITests/WordPressOrgAPITests.swift similarity index 99% rename from Tests/WordPressKitTests/Tests/WordPressAPI/WordPressOrgAPITests.swift rename to Tests/CoreAPITests/WordPressOrgAPITests.swift index 5521373ad..6b3a6b311 100644 --- a/Tests/WordPressKitTests/Tests/WordPressAPI/WordPressOrgAPITests.swift +++ b/Tests/CoreAPITests/WordPressOrgAPITests.swift @@ -1,8 +1,11 @@ -import Foundation import XCTest import OHHTTPStubs - +#if SWIFT_PACKAGE +@testable import CoreAPI +import OHHTTPStubsSwift +#else @testable import WordPressKit +#endif class WordPressOrgAPITests: XCTestCase { diff --git a/Tests/WordPressKitTests/Tests/WordPressOrgRestApiTests.swift b/Tests/CoreAPITests/WordPressOrgRestApiTests.swift similarity index 94% rename from Tests/WordPressKitTests/Tests/WordPressOrgRestApiTests.swift rename to Tests/CoreAPITests/WordPressOrgRestApiTests.swift index ec2ac0b9a..595d2c5d0 100644 --- a/Tests/WordPressKitTests/Tests/WordPressOrgRestApiTests.swift +++ b/Tests/CoreAPITests/WordPressOrgRestApiTests.swift @@ -1,7 +1,11 @@ -import Foundation import XCTest import OHHTTPStubs +#if SWIFT_PACKAGE +@testable import CoreAPI +import OHHTTPStubsSwift +#else @testable import WordPressKit +#endif class WordPressOrgRestApiTests: XCTestCase { @@ -23,7 +27,7 @@ class WordPressOrgRestApiTests: XCTestCase { } func testUnauthorizedCall() async throws { - let stubPath = try XCTUnwrap(OHPathForFile("wp-forbidden.json", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("wp-forbidden.json", Bundle.coreAPITestsBundle)) stub(condition: isAPIRequest()) { _ in return fixture(filePath: stubPath, status: 401, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) } @@ -38,7 +42,7 @@ class WordPressOrgRestApiTests: XCTestCase { } func testSuccessfulGetCall() async throws { - let stubPath = try XCTUnwrap(OHPathForFile("wp-pages.json", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("wp-pages.json", Bundle.coreAPITestsBundle)) stub(condition: isAPIRequest()) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) } @@ -48,7 +52,7 @@ class WordPressOrgRestApiTests: XCTestCase { } func testSuccessfulPostCall() async throws { - let stubPath = try XCTUnwrap(OHPathForFile("wp-reusable-blocks.json", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("wp-reusable-blocks.json", Bundle.coreAPITestsBundle)) stub(condition: isAPIRequest()) { _ in return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) } diff --git a/Tests/WordPressKitTests/Tests/WordPressOrgXMLRPCApiTests.swift b/Tests/CoreAPITests/WordPressOrgXMLRPCApiTests.swift similarity index 89% rename from Tests/WordPressKitTests/Tests/WordPressOrgXMLRPCApiTests.swift rename to Tests/CoreAPITests/WordPressOrgXMLRPCApiTests.swift index f536e8930..b198c5d09 100644 --- a/Tests/WordPressKitTests/Tests/WordPressOrgXMLRPCApiTests.swift +++ b/Tests/CoreAPITests/WordPressOrgXMLRPCApiTests.swift @@ -1,8 +1,12 @@ -import Foundation import XCTest import OHHTTPStubs import wpxmlrpc +#if SWIFT_PACKAGE +@testable import CoreAPI +import OHHTTPStubsSwift +#else @testable import WordPressKit +#endif class WordPressOrgXMLRPCApiTests: XCTestCase { @@ -25,7 +29,7 @@ class WordPressOrgXMLRPCApiTests: XCTestCase { } func testSuccessfullCall() throws { - let stubPath = try XCTUnwrap(OHPathForFile("xmlrpc-response-getpost.xml", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("xmlrpc-response-getpost.xml", Bundle.coreAPITestsBundle)) stub(condition: isXmlRpcAPIRequest()) { _ in return fixture(filePath: stubPath, headers: self.xmlContentTypeHeaders) } @@ -59,8 +63,12 @@ class WordPressOrgXMLRPCApiTests: XCTestCase { }, failure: { (error, _) in expect.fulfill() - + // When building for SPM, the compiler doesn't generate the domain constant. +#if SWIFT_PACKAGE + XCTAssertEqual(error.domain, "CoreAPI.WordPressOrgXMLRPCApiError") +#else XCTAssertEqual(error.domain, WordPressOrgXMLRPCApiErrorDomain) +#endif XCTAssertEqual(error.code, WordPressOrgXMLRPCApiError.httpErrorStatusCode.rawValue) XCTAssertEqual(error.localizedFailureReason, "An HTTP error code 404 was returned.") XCTAssertNotNil(error.userInfo[WordPressOrgXMLRPCApi.WordPressOrgXMLRPCApiErrorKeyData as String]) @@ -88,7 +96,12 @@ class WordPressOrgXMLRPCApiTests: XCTestCase { expect.fulfill() XCTAssertFalse(error is WordPressOrgXMLRPCApiError) + // When building for SPM, the compiler doesn't generate the domain constant. +#if SWIFT_PACKAGE + XCTAssertEqual(error.domain, "CoreAPI.WordPressOrgXMLRPCApiError") +#else XCTAssertEqual(error.domain, WordPressOrgXMLRPCApiErrorDomain) +#endif XCTAssertEqual(error.code, 403) XCTAssertEqual(error.localizedFailureReason, "An HTTP error code 403 was returned.") XCTAssertNotNil(error.userInfo[WordPressOrgXMLRPCApi.WordPressOrgXMLRPCApiErrorKeyData as String]) @@ -116,7 +129,12 @@ class WordPressOrgXMLRPCApiTests: XCTestCase { expect.fulfill() XCTAssertTrue(error is WordPressOrgXMLRPCApiError) + // When building for SPM, the compiler doesn't generate the domain constant. +#if SWIFT_PACKAGE + XCTAssertEqual(error.domain, "CoreAPI.WordPressOrgXMLRPCApiError") +#else XCTAssertEqual(error.domain, WordPressOrgXMLRPCApiErrorDomain) +#endif XCTAssertEqual(error.code, WordPressOrgXMLRPCApiError.unknown.rawValue) XCTAssertEqual(error.localizedFailureReason, WordPressOrgXMLRPCApiError.unknown.failureReason) XCTAssertNotNil(error.userInfo[WordPressOrgXMLRPCApi.WordPressOrgXMLRPCApiErrorKeyData as String]) @@ -152,7 +170,7 @@ class WordPressOrgXMLRPCApiTests: XCTestCase { } func testFault() throws { - let responseFile = try XCTUnwrap(OHPathForFile("xmlrpc-bad-username-password-error.xml", WordPressOrgXMLRPCApiTests.self)) + let responseFile = try XCTUnwrap(OHPathForFileInBundle("xmlrpc-bad-username-password-error.xml", Bundle.coreAPITestsBundle)) stub(condition: isXmlRpcAPIRequest()) { _ in fixture(filePath: responseFile, headers: self.xmlContentTypeHeaders) } @@ -180,7 +198,7 @@ class WordPressOrgXMLRPCApiTests: XCTestCase { } func testFault401() throws { - let responseFile = try XCTUnwrap(OHPathForFile("xmlrpc-bad-username-password-error.xml", WordPressOrgXMLRPCApiTests.self)) + let responseFile = try XCTUnwrap(OHPathForFileInBundle("xmlrpc-bad-username-password-error.xml", Bundle.coreAPITestsBundle)) stub(condition: isXmlRpcAPIRequest()) { _ in fixture(filePath: responseFile, status: 401, headers: self.xmlContentTypeHeaders) } @@ -237,7 +255,7 @@ class WordPressOrgXMLRPCApiTests: XCTestCase { } func testInvalidXML() throws { - let responseFile = try XCTUnwrap(OHPathForFile("xmlrpc-response-invalid.html", WordPressOrgXMLRPCApiTests.self)) + let responseFile = try XCTUnwrap(OHPathForFileInBundle("xmlrpc-response-invalid.html", Bundle.coreAPITestsBundle)) stub(condition: isXmlRpcAPIRequest()) { _ in fixture(filePath: responseFile, headers: self.xmlContentTypeHeaders) } @@ -264,7 +282,7 @@ class WordPressOrgXMLRPCApiTests: XCTestCase { } func testProgressUpdate() throws { - let stubPath = try XCTUnwrap(OHPathForFile("xmlrpc-response-getpost.xml", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("xmlrpc-response-getpost.xml", Bundle.coreAPITestsBundle)) stub(condition: isXmlRpcAPIRequest()) { _ in return fixture(filePath: stubPath, headers: self.xmlContentTypeHeaders) } @@ -292,7 +310,7 @@ class WordPressOrgXMLRPCApiTests: XCTestCase { } func testProgressUpdateFailure() throws { - let stubPath = try XCTUnwrap(OHPathForFile("xmlrpc-bad-username-password-error.xml", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("xmlrpc-bad-username-password-error.xml", Bundle.coreAPITestsBundle)) stub(condition: isXmlRpcAPIRequest()) { _ in return fixture(filePath: stubPath, headers: self.xmlContentTypeHeaders) } @@ -320,7 +338,7 @@ class WordPressOrgXMLRPCApiTests: XCTestCase { } func testProgressUpdateStreamAPI() throws { - let stubPath = try XCTUnwrap(OHPathForFile("xmlrpc-response-getpost.xml", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("xmlrpc-response-getpost.xml", Bundle.coreAPITestsBundle)) stub(condition: isXmlRpcAPIRequest()) { _ in return fixture(filePath: stubPath, headers: self.xmlContentTypeHeaders) } @@ -348,7 +366,7 @@ class WordPressOrgXMLRPCApiTests: XCTestCase { } func testProgressUpdateStreamAPIFailure() throws { - let stubPath = try XCTUnwrap(OHPathForFile("xmlrpc-bad-username-password-error.xml", type(of: self))) + let stubPath = try XCTUnwrap(OHPathForFileInBundle("xmlrpc-bad-username-password-error.xml", Bundle.coreAPITestsBundle)) stub(condition: isXmlRpcAPIRequest()) { _ in return fixture(filePath: stubPath, headers: self.xmlContentTypeHeaders) } diff --git a/Tests/WordPressKitTests/Tests/WordPressAPI/WordPressOrgXMLRPCValidatorTests.swift b/Tests/CoreAPITests/WordPressOrgXMLRPCValidatorTests.swift similarity index 88% rename from Tests/WordPressKitTests/Tests/WordPressAPI/WordPressOrgXMLRPCValidatorTests.swift rename to Tests/CoreAPITests/WordPressOrgXMLRPCValidatorTests.swift index 0b4e086be..3a79b643d 100644 --- a/Tests/WordPressKitTests/Tests/WordPressAPI/WordPressOrgXMLRPCValidatorTests.swift +++ b/Tests/CoreAPITests/WordPressOrgXMLRPCValidatorTests.swift @@ -1,7 +1,11 @@ import XCTest import OHHTTPStubs - +#if SWIFT_PACKAGE +@testable import CoreAPI +import OHHTTPStubsSwift +#else @testable import WordPressKit +#endif final class WordPressOrgXMLRPCValidatorTests: XCTestCase { @@ -87,24 +91,16 @@ final class WordPressOrgXMLRPCValidatorTests: XCTestCase { XCTAssertEqual(schemes, Set(arrayLiteral: "https", "http")) } - func testNotWordPressSiteError() { + func testNotWordPressSiteError() throws { // Create HTTP stubs to simulate a plain static website // - Return a plain HTML webpage for all GET requests // - Return a 405 method not allowed error for all POST requests - + let path = try XCTUnwrap(xmlrpcResponseInvalidPath) stub(condition: isHost("www.apple.com") && isMethodGET()) { _ in - fixture( - filePath: OHPathForFile("xmlrpc-response-invalid.html", type(of: self))!, - status: 200, - headers: nil - ) + fixture(filePath: path, status: 200, headers: nil) } stub(condition: isHost("www.apple.com") && isMethodPOST()) { _ in - fixture( - filePath: OHPathForFile("xmlrpc-response-invalid.html", type(of: self))!, - status: 405, - headers: nil - ) + fixture(filePath: path, status: 405, headers: nil) } let failure = self.expectation(description: "returns error") @@ -122,10 +118,13 @@ final class WordPressOrgXMLRPCValidatorTests: XCTestCase { wait(for: [failure], timeout: 0.3) } - func testSuccessWithSiteAddress() { + func testSuccessWithSiteAddress() throws { + let path = try XCTUnwrap( + OHPathForFileInBundle("xmlrpc-response-list-methods.xml", Bundle.coreAPITestsBundle) + ) stub(condition: isHost("www.apple.com") && isPath("/blog/xmlrpc.php")) { _ in fixture( - filePath: OHPathForFile("xmlrpc-response-list-methods.xml", type(of: self))!, + filePath: path, status: 200, headers: [ "Content-Type": "application/xml" @@ -144,25 +143,25 @@ final class WordPressOrgXMLRPCValidatorTests: XCTestCase { wait(for: [success], timeout: 0.3) } - func testSuccessWithIrregularXMLRPCAddress() { + func testSuccessWithIrregularXMLRPCAddress() throws { let apiCalls = [ expectation(description: "Request #1: call xmlrpc.php"), expectation(description: "Request #2: call the url argument"), ] + let responseInvalidPath = try XCTUnwrap(xmlrpcResponseInvalidPath) stub(condition: isHost("www.apple.com") && isPath("/blog/xmlrpc.php")) { _ in apiCalls[0].fulfill() - return fixture( - filePath: OHPathForFile("xmlrpc-response-invalid.html", type(of: self))!, - status: 403, - headers: nil - ) + return fixture(filePath: responseInvalidPath, status: 403, headers: nil) } + let responseListPath = try XCTUnwrap( + OHPathForFileInBundle("xmlrpc-response-list-methods.xml", Bundle.coreAPITestsBundle) + ) stub(condition: isHost("www.apple.com") && isPath("/blog")) { _ in apiCalls[1].fulfill() return fixture( - filePath: OHPathForFile("xmlrpc-response-list-methods.xml", type(of: self))!, + filePath: responseListPath, status: 200, headers: [ "Content-Type": "application/xml" @@ -181,13 +180,10 @@ final class WordPressOrgXMLRPCValidatorTests: XCTestCase { wait(for: apiCalls + [success], timeout: 0.3, enforceOrder: true) } - func testSuccessWithRSDLink() { + func testSuccessWithRSDLink() throws { + let responseInvalidPath = try XCTUnwrap(xmlrpcResponseInvalidPath) stub(condition: isHost("www.apple.com") && isPath("/blog/xmlrpc.php")) { _ in - return fixture( - filePath: OHPathForFile("xmlrpc-response-invalid.html", type(of: self))!, - status: 403, - headers: nil - ) + return fixture(filePath: responseInvalidPath, status: 403, headers: nil) } stub(condition: isHost("www.apple.com") && isPath("/blog")) { _ in @@ -231,9 +227,12 @@ final class WordPressOrgXMLRPCValidatorTests: XCTestCase { ) } + let responseList = try XCTUnwrap( + OHPathForFileInBundle("xmlrpc-response-list-methods.xml", Bundle.coreAPITestsBundle) + ) stub(condition: isHost("www.apple.com") && isPath("/blog-xmlrpc.php")) { _ in fixture( - filePath: OHPathForFile("xmlrpc-response-list-methods.xml", type(of: self))!, + filePath: responseList, status: 200, headers: [ "Content-Type": "application/xml" @@ -252,7 +251,7 @@ final class WordPressOrgXMLRPCValidatorTests: XCTestCase { wait(for: [success], timeout: 0.3) } - func testManyRedirectsError() { + func testManyRedirectsError() throws { // redirect 'POST /redirect/' to '/redirect/'. for number in 1...30 { stub(condition: isMethodPOST() && { $0.url!.path.hasPrefix("/redirect/\(number)-req") }) { @@ -263,12 +262,9 @@ final class WordPressOrgXMLRPCValidatorTests: XCTestCase { } // All GET requests get a html webpage. + let path = try XCTUnwrap(xmlrpcResponseInvalidPath) stub(condition: isMethodGET()) { _ in - fixture( - filePath: OHPathForFile("xmlrpc-response-invalid.html", type(of: self))!, - status: 405, - headers: nil - ) + fixture(filePath: path, status: 405, headers: nil) } let failure = self.expectation(description: "returns error") @@ -288,16 +284,19 @@ final class WordPressOrgXMLRPCValidatorTests: XCTestCase { wait(for: [failure], timeout: 0.3) } - func testMobilePluginRedirectedError() { + func testMobilePluginRedirectedError() throws { // redirect 'POST /redirect/' to '/redirect/'. stub(condition: isMethodPOST() && isHost("www.apple.com")) { _ in HTTPStubsResponse(data: Data(), statusCode: 302, headers: [ "Location": "https://m.apple.com" ]) } + let path = try XCTUnwrap( + OHPathForFileInBundle("xmlrpc-response-mobile-plugin-redirect.html", Bundle.coreAPITestsBundle) + ) stub(condition: isMethodPOST() && isHost("m.apple.com")) { _ in fixture( - filePath: OHPathForFile("xmlrpc-response-mobile-plugin-redirect.html", type(of: self))!, + filePath: path, status: 200, headers: nil ) @@ -376,6 +375,10 @@ final class WordPressOrgXMLRPCValidatorTests: XCTestCase { wait(for: [failure], timeout: 0.3) } + let xmlrpcResponseInvalidPath = OHPathForFileInBundle( + "xmlrpc-response-invalid.html", + Bundle.coreAPITestsBundle + ) } private extension WordPressOrgXMLRPCValidatorTests { diff --git a/WordPressKit.xcodeproj/project.pbxproj b/WordPressKit.xcodeproj/project.pbxproj index 91cda36e1..1c1f29298 100644 --- a/WordPressKit.xcodeproj/project.pbxproj +++ b/WordPressKit.xcodeproj/project.pbxproj @@ -69,7 +69,6 @@ 3FB8642C2888089F003A86BE /* BuildkiteTestCollector in Frameworks */ = {isa = PBXBuildFile; productRef = 3FB8642B2888089F003A86BE /* BuildkiteTestCollector */; }; 3FD634E52BC3A55F00CEDF5E /* WordPressOrgXMLRPCValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FD634E32BC3A55F00CEDF5E /* WordPressOrgXMLRPCValidator.swift */; }; 3FD634E62BC3A55F00CEDF5E /* Date+WordPressCom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FD634E42BC3A55F00CEDF5E /* Date+WordPressCom.swift */; }; - 3FD634EA2BC3A6BA00CEDF5E /* Bundle+SPMSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FD634E92BC3A6BA00CEDF5E /* Bundle+SPMSupport.swift */; }; 3FD634F22BC3AD6200CEDF5E /* MultipartForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FD634EB2BC3AD6200CEDF5E /* MultipartForm.swift */; }; 3FD634F32BC3AD6200CEDF5E /* Result+Callback.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FD634EC2BC3AD6200CEDF5E /* Result+Callback.swift */; }; 3FD634F42BC3AD6200CEDF5E /* Either.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FD634ED2BC3AD6200CEDF5E /* Either.swift */; }; @@ -77,6 +76,9 @@ 3FD634F62BC3AD6200CEDF5E /* AppTransportSecuritySettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FD634EF2BC3AD6200CEDF5E /* AppTransportSecuritySettings.swift */; }; 3FD634F72BC3AD6200CEDF5E /* WebauthChallengeInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FD634F02BC3AD6200CEDF5E /* WebauthChallengeInfo.swift */; }; 3FD634F82BC3AD6200CEDF5E /* StringEncoding+IANA.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FD634F12BC3AD6200CEDF5E /* StringEncoding+IANA.swift */; }; + 3FD634FA2BC3AE6800CEDF5E /* AppTransportSecuritySettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46ABD0E9262EEE0400C7FF24 /* AppTransportSecuritySettingsTests.swift */; }; + 3FD634FB2BC3AE6C00CEDF5E /* Bundle+SPMSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FD634E92BC3A6BA00CEDF5E /* Bundle+SPMSupport.swift */; }; + 3FD634FF2BC3B3D400CEDF5E /* WordPressComRestApiErrorDomain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FD634FE2BC3B3D400CEDF5E /* WordPressComRestApiErrorDomain.swift */; }; 3FE2E94F2BB29A1B002CA2E1 /* FilePart.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FE2E94D2BB29A1B002CA2E1 /* FilePart.m */; }; 3FE2E9502BB29A1B002CA2E1 /* FilePart.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FE2E94E2BB29A1B002CA2E1 /* FilePart.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3FE2E9672BBEB8D2002CA2E1 /* WordPressComRESTAPIVersion.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FE2E9662BBEB8D2002CA2E1 /* WordPressComRESTAPIVersion.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -166,12 +168,11 @@ 465F88BF263B54EE00F4C950 /* ChecksumUtilTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 465F88BE263B54EE00F4C950 /* ChecksumUtilTests.swift */; }; 46ABD0E0262EED3D00C7FF24 /* WordPressOrgXMLRPCValidatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46ABD0DF262EED3D00C7FF24 /* WordPressOrgXMLRPCValidatorTests.swift */; }; 46ABD0E6262EEDAB00C7FF24 /* FakeInfoDictionaryObjectProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46ABD0E5262EEDAB00C7FF24 /* FakeInfoDictionaryObjectProvider.swift */; }; - 46ABD0EA262EEE0400C7FF24 /* AppTransportSecuritySettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46ABD0E9262EEE0400C7FF24 /* AppTransportSecuritySettingsTests.swift */; }; 4A05E7962B2FCB6400C25E3B /* NonceRetrieval.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A05E7952B2FCB6400C25E3B /* NonceRetrieval.swift */; }; 4A05E7982B2FCB9A00C25E3B /* NonceRetrievalTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A05E7972B2FCB9A00C25E3B /* NonceRetrievalTests.swift */; }; 4A05E79A2B2FDC3200C25E3B /* WordPressOrgRestApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A05E7992B2FDC3200C25E3B /* WordPressOrgRestApi.swift */; }; 4A05E79C2B2FDC6100C25E3B /* WordPressOrgAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A05E79B2B2FDC6100C25E3B /* WordPressOrgAPITests.swift */; }; - 4A05E79E2B30F3C500C25E3B /* HTTPRequestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A05E79D2B30F3C500C25E3B /* HTTPRequestHelpers.swift */; }; + 4A05E79E2B30F3C500C25E3B /* URLRequest+HTTPBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A05E79D2B30F3C500C25E3B /* URLRequest+HTTPBodyText.swift */; }; 4A05E7A62B34142200C25E3B /* xmlrpc-response-invalid.html in Resources */ = {isa = PBXBuildFile; fileRef = 4A05E7A52B34142200C25E3B /* xmlrpc-response-invalid.html */; }; 4A05E7A82B34EAF400C25E3B /* xmlrpc-response-mobile-plugin-redirect.html in Resources */ = {isa = PBXBuildFile; fileRef = 4A05E7A72B34EAF400C25E3B /* xmlrpc-response-mobile-plugin-redirect.html */; }; 4A05E7AA2B34FC4300C25E3B /* xmlrpc-response-list-methods.xml in Resources */ = {isa = PBXBuildFile; fileRef = 4A05E7A92B34FC4300C25E3B /* xmlrpc-response-list-methods.xml */; }; @@ -187,8 +188,6 @@ 4A3239682B74319400EFD2A8 /* self-hosted-plugins-install.json in Resources */ = {isa = PBXBuildFile; fileRef = 4A3239672B74319400EFD2A8 /* self-hosted-plugins-install.json */; }; 4A40F6552B2A5A1A0015DA77 /* WordPressAPIErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A40F6542B2A5A1A0015DA77 /* WordPressAPIErrorTests.swift */; }; 4A57A6812B549144008D0660 /* WordPressComRestApiTests+Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A57A6802B549144008D0660 /* WordPressComRestApiTests+Error.swift */; }; - 4A57A6872B54C68C008D0660 /* Constants.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A57A6852B54C68C008D0660 /* Constants.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4A57A6882B54C68C008D0660 /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A57A6862B54C68C008D0660 /* Constants.m */; }; 4A68E3CD29404181004AC3DC /* RemoteBlog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A68E3CC29404181004AC3DC /* RemoteBlog.swift */; }; 4A68E3CF29404289004AC3DC /* RemoteBlogOptionsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A68E3CE29404289004AC3DC /* RemoteBlogOptionsHelper.swift */; }; 4A68E3D329406AA0004AC3DC /* RemoteMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A68E3D029406AA0004AC3DC /* RemoteMenu.swift */; }; @@ -824,6 +823,7 @@ 3FD634EF2BC3AD6200CEDF5E /* AppTransportSecuritySettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppTransportSecuritySettings.swift; sourceTree = ""; }; 3FD634F02BC3AD6200CEDF5E /* WebauthChallengeInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebauthChallengeInfo.swift; sourceTree = ""; }; 3FD634F12BC3AD6200CEDF5E /* StringEncoding+IANA.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StringEncoding+IANA.swift"; sourceTree = ""; }; + 3FD634FE2BC3B3D400CEDF5E /* WordPressComRestApiErrorDomain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressComRestApiErrorDomain.swift; sourceTree = ""; }; 3FE2E94D2BB29A1B002CA2E1 /* FilePart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FilePart.m; sourceTree = ""; }; 3FE2E94E2BB29A1B002CA2E1 /* FilePart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilePart.h; sourceTree = ""; }; 3FE2E9662BBEB8D2002CA2E1 /* WordPressComRESTAPIVersion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WordPressComRESTAPIVersion.h; sourceTree = ""; }; @@ -918,7 +918,7 @@ 4A05E7972B2FCB9A00C25E3B /* NonceRetrievalTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NonceRetrievalTests.swift; sourceTree = ""; }; 4A05E7992B2FDC3200C25E3B /* WordPressOrgRestApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WordPressOrgRestApi.swift; sourceTree = ""; }; 4A05E79B2B2FDC6100C25E3B /* WordPressOrgAPITests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WordPressOrgAPITests.swift; sourceTree = ""; }; - 4A05E79D2B30F3C500C25E3B /* HTTPRequestHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPRequestHelpers.swift; sourceTree = ""; }; + 4A05E79D2B30F3C500C25E3B /* URLRequest+HTTPBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLRequest+HTTPBodyText.swift"; sourceTree = ""; }; 4A05E7A52B34142200C25E3B /* xmlrpc-response-invalid.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "xmlrpc-response-invalid.html"; sourceTree = ""; }; 4A05E7A72B34EAF400C25E3B /* xmlrpc-response-mobile-plugin-redirect.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "xmlrpc-response-mobile-plugin-redirect.html"; sourceTree = ""; }; 4A05E7A92B34FC4300C25E3B /* xmlrpc-response-list-methods.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "xmlrpc-response-list-methods.xml"; sourceTree = ""; }; @@ -934,8 +934,6 @@ 4A3239672B74319400EFD2A8 /* self-hosted-plugins-install.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "self-hosted-plugins-install.json"; sourceTree = ""; }; 4A40F6542B2A5A1A0015DA77 /* WordPressAPIErrorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressAPIErrorTests.swift; sourceTree = ""; }; 4A57A6802B549144008D0660 /* WordPressComRestApiTests+Error.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WordPressComRestApiTests+Error.swift"; sourceTree = ""; }; - 4A57A6852B54C68C008D0660 /* Constants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = ""; }; - 4A57A6862B54C68C008D0660 /* Constants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Constants.m; sourceTree = ""; }; 4A68E3CC29404181004AC3DC /* RemoteBlog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteBlog.swift; sourceTree = ""; }; 4A68E3CE29404289004AC3DC /* RemoteBlogOptionsHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteBlogOptionsHelper.swift; sourceTree = ""; }; 4A68E3D029406AA0004AC3DC /* RemoteMenu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteMenu.swift; sourceTree = ""; }; @@ -1562,11 +1560,44 @@ 3FD634E82BC3A6A800CEDF5E /* CoreAPITests */ = { isa = PBXGroup; children = ( + 3FD634FC2BC3B23600CEDF5E /* Stubs */, + 46ABD0E9262EEE0400C7FF24 /* AppTransportSecuritySettingsTests.swift */, 3FD634E92BC3A6BA00CEDF5E /* Bundle+SPMSupport.swift */, + 46ABD0E5262EEDAB00C7FF24 /* FakeInfoDictionaryObjectProvider.swift */, + 4A6B4A832B26974F00802316 /* HTTPRequestBuilderTests.swift */, + 4A1123A12B19690C004690CF /* MultipartFormTests.swift */, + 4A05E7972B2FCB9A00C25E3B /* NonceRetrievalTests.swift */, + 4A05E7AB2B35048A00C25E3B /* RSDParserTests.swift */, + 4A05E79D2B30F3C500C25E3B /* URLRequest+HTTPBodyText.swift */, + FFE247A620C891D1002DF3A2 /* WordPressComOAuthClientTests.swift */, + 74B335D91F06F3D60053A184 /* WordPressComRestApiTests.swift */, + 4A57A6802B549144008D0660 /* WordPressComRestApiTests+Error.swift */, + 73B3DAD521FBB20D00B2CF18 /* WordPressComRestApiTests+Locale.swift */, + 4A05E79B2B2FDC6100C25E3B /* WordPressOrgAPITests.swift */, + FFA4D4A82423B10A00BF5180 /* WordPressOrgRestApiTests.swift */, + 74B335DB1F06F4180053A184 /* WordPressOrgXMLRPCApiTests.swift */, + 46ABD0DF262EED3D00C7FF24 /* WordPressOrgXMLRPCValidatorTests.swift */, ); path = CoreAPITests; sourceTree = ""; }; + 3FD634FC2BC3B23600CEDF5E /* Stubs */ = { + isa = PBXGroup; + children = ( + 3FD634FD2BC3B25400CEDF5E /* HTML */, + ); + path = Stubs; + sourceTree = ""; + }; + 3FD634FD2BC3B25400CEDF5E /* HTML */ = { + isa = PBXGroup; + children = ( + 4A05E7A52B34142200C25E3B /* xmlrpc-response-invalid.html */, + 4A05E7A72B34EAF400C25E3B /* xmlrpc-response-mobile-plugin-redirect.html */, + ); + path = HTML; + sourceTree = ""; + }; 3FE2E9362BB10EC7002CA2E1 /* Stats */ = { isa = PBXGroup; children = ( @@ -1840,8 +1871,6 @@ 465F88A1263B325C00F4C950 /* ChecksumUtil.swift */, 3F3195AC266FF94B00397EE7 /* ZendeskMetadata.swift */, 4AE278432B2FAF6200E4D9B1 /* HTTPProtocolHelpers.swift */, - 4A57A6852B54C68C008D0660 /* Constants.h */, - 4A57A6862B54C68C008D0660 /* Constants.m */, ); path = Utility; sourceTree = ""; @@ -1945,12 +1974,6 @@ 93F50A431F227CFB00B5BEBA /* UsersServiceRemoteXMLRPCTests.swift */, F9E56DF924EB18A300916770 /* Utilities */, 57A38E502624F7D000472480 /* WordPressAPI */, - FFE247A620C891D1002DF3A2 /* WordPressComOAuthClientTests.swift */, - 74B335D91F06F3D60053A184 /* WordPressComRestApiTests.swift */, - 73B3DAD521FBB20D00B2CF18 /* WordPressComRestApiTests+Locale.swift */, - 4A57A6802B549144008D0660 /* WordPressComRestApiTests+Error.swift */, - FFA4D4A82423B10A00BF5180 /* WordPressOrgRestApiTests.swift */, - 74B335DB1F06F4180053A184 /* WordPressOrgXMLRPCApiTests.swift */, 740B23D51F17F7C100067A2A /* XMLRPCTestable.swift */, 3FFCC0402BA995290051D229 /* Date+WordPressComTests.swift */, 3FFCC04C2BABA6980051D229 /* NSDate+WordPressComTests.swift */, @@ -2055,6 +2078,7 @@ 3FE2E9792BC3A332002CA2E1 /* WordPressAPIError+NSErrorBridge.swift */, 93BD27771EE73944002BB00B /* WordPressComOAuthClient.swift */, 3FE2E97A2BC3A332002CA2E1 /* WordPressComRestApi.swift */, + 3FD634FE2BC3B3D400CEDF5E /* WordPressComRestApiErrorDomain.swift */, 4A05E7992B2FDC3200C25E3B /* WordPressOrgRestApi.swift */, 93BD27791EE73944002BB00B /* WordPressOrgXMLRPCApi.swift */, 3FD634E32BC3A55F00CEDF5E /* WordPressOrgXMLRPCValidator.swift */, @@ -2113,9 +2137,6 @@ 57A38E502624F7D000472480 /* WordPressAPI */ = { isa = PBXGroup; children = ( - 46ABD0DF262EED3D00C7FF24 /* WordPressOrgXMLRPCValidatorTests.swift */, - 4A05E7972B2FCB9A00C25E3B /* NonceRetrievalTests.swift */, - 4A05E79B2B2FDC6100C25E3B /* WordPressOrgAPITests.swift */, ); path = WordPressAPI; sourceTree = ""; @@ -2123,7 +2144,6 @@ 57A38E572624FF1000472480 /* Fakes */ = { isa = PBXGroup; children = ( - 46ABD0E5262EEDAB00C7FF24 /* FakeInfoDictionaryObjectProvider.swift */, ); path = Fakes; sourceTree = ""; @@ -2449,8 +2469,6 @@ 740B23DD1F17FB4200067A2A /* xmlrpc-metaweblog-newpost-success.xml */, 74B335E91F06F76B0053A184 /* xmlrpc-response-getpost.xml */, 4A05E7A92B34FC4300C25E3B /* xmlrpc-response-list-methods.xml */, - 4A05E7A52B34142200C25E3B /* xmlrpc-response-invalid.html */, - 4A05E7A72B34EAF400C25E3B /* xmlrpc-response-mobile-plugin-redirect.html */, 93F50A451F227F3600B5BEBA /* xmlrpc-response-getprofile.xml */, 93F50A461F227F3600B5BEBA /* xmlrpc-response-valid-but-unexpected-dictionary.xml */, 98EA910426BC96B8004098A1 /* xmlrpc-site-comments-success.xml */, @@ -2584,21 +2602,16 @@ F9E56DF924EB18A300916770 /* Utilities */ = { isa = PBXGroup; children = ( - 46ABD0E9262EEE0400C7FF24 /* AppTransportSecuritySettingsTests.swift */, F9E56DFA24EB18C300916770 /* FeatureFlagRemoteTests.swift */, 24ADA24D24F9B32D001B5DAE /* FeatureFlagSerializationTest.swift */, 465F88BE263B54EE00F4C950 /* ChecksumUtilTests.swift */, 803DE81028FFA9C4007D4E9C /* RemoteConfigRemoteTests.swift */, 4A1DEF43293051BC00322608 /* LoggingTests.swift */, 4A1DEF45293051C600322608 /* LoggingTests.m */, - 4A1123A12B19690C004690CF /* MultipartFormTests.swift */, - 4A6B4A832B26974F00802316 /* HTTPRequestBuilderTests.swift */, 4A6B4A852B269D0C00802316 /* URLSessionHelperTests.swift */, 4A40F6542B2A5A1A0015DA77 /* WordPressAPIErrorTests.swift */, 4AE278472B2FBF1100E4D9B1 /* HTTPBodyEncodingTests.swift */, 4AE278492B2FC6C600E4D9B1 /* HTTPHeaderValueParserTests.swift */, - 4A05E7AB2B35048A00C25E3B /* RSDParserTests.swift */, - 4A05E79D2B30F3C500C25E3B /* HTTPRequestHelpers.swift */, ); path = Utilities; sourceTree = ""; @@ -2676,7 +2689,6 @@ 740B23C41F17EE8000067A2A /* RemotePost.h in Headers */, 740B23C21F17EE8000067A2A /* RemotePostCategory.h in Headers */, B5A4822F20AC6C1A009D95F6 /* WPKitLogging.h in Headers */, - 4A57A6872B54C68C008D0660 /* Constants.h in Headers */, 9309995B1F16616A00F006A1 /* RemoteTheme.h in Headers */, 1A4F98672279A87D00D86E8E /* WPKit-Swift.h in Headers */, 93F50A371F226B9300B5BEBA /* WordPressComServiceRemote.h in Headers */, @@ -3281,7 +3293,6 @@ C797196E2679007B0072F984 /* SelfHostedPluginManagementClient.swift in Sources */, 40414060220F9F1F00CF7C5B /* StatsAllTimesInsight.swift in Sources */, E194CB731FBDEF6500B0A8B8 /* PluginState.swift in Sources */, - 4A57A6882B54C68C008D0660 /* Constants.m in Sources */, 404057D6221C92660060250C /* StatsTopClicksTimeIntervalData.swift in Sources */, 3FD634F42BC3AD6200CEDF5E /* Either.swift in Sources */, 9AF4F2FC218331DC00570E4B /* PostServiceRemoteREST+Revisions.swift in Sources */, @@ -3366,7 +3377,6 @@ 0C1C08412B9CD79900E52F8C /* PostServiceRemoteExtended.swift in Sources */, 9AF4F2FF2183346B00570E4B /* RemoteRevision.swift in Sources */, FE6C673A2BB739950083ECAB /* Decodable+Dictionary.swift in Sources */, - 3FD634EA2BC3A6BA00CEDF5E /* Bundle+SPMSupport.swift in Sources */, 17D936252475D8AB008B2205 /* RemoteHomepageType.swift in Sources */, 74BA04F41F06DC0A00ED5CD8 /* CommentServiceRemoteREST.m in Sources */, 74C473AC1EF2F75E009918F2 /* SiteManagementServiceRemote.swift in Sources */, @@ -3402,6 +3412,7 @@ 9FCDD09720A5EF75004F0BF7 /* ReaderTopicServiceError.swift in Sources */, 74A44DD11F13C64B006CD8F4 /* RemoteNotificationSettings.swift in Sources */, FEF7419D28085D89002C4203 /* RemoteBloggingPrompt.swift in Sources */, + 3FD634FF2BC3B3D400CEDF5E /* WordPressComRestApiErrorDomain.swift in Sources */, 74DA56331F06EAF000FE9BF4 /* MediaServiceRemoteREST.m in Sources */, 17CD0CC320C58A0D000D9620 /* ReaderSiteSearchServiceRemote.swift in Sources */, 74DA563B1F06EB3000FE9BF4 /* RemoteMedia.m in Sources */, @@ -3455,12 +3466,11 @@ FE5096682A309E4600DDD071 /* JetpackSocialServiceRemoteTests.swift in Sources */, 74A44DD41F13C6D8006CD8F4 /* RemoteNotificationTests.swift in Sources */, 74A923B21F2BE2DF00EC8F92 /* RESTTestable.swift in Sources */, - 46ABD0EA262EEE0400C7FF24 /* AppTransportSecuritySettingsTests.swift in Sources */, 74D67F0A1F15C24C0010C5ED /* PeopleServiceRemoteTests.swift in Sources */, 4A1123A22B19690C004690CF /* MultipartFormTests.swift in Sources */, B04D8C0D2BB7895A002717A2 /* StatsInsightDecodingTests.swift in Sources */, 9F3E0BAE20873836009CB5BA /* ReaderTopicServiceRemoteTest+Subscriptions.swift in Sources */, - 4A05E79E2B30F3C500C25E3B /* HTTPRequestHelpers.swift in Sources */, + 4A05E79E2B30F3C500C25E3B /* URLRequest+HTTPBodyText.swift in Sources */, BA0637ED2492382200AF8419 /* PluginStateTests.swift in Sources */, 7328420621CD798A00126755 /* WordPressComServiceRemoteTests+SiteCreation.swift in Sources */, FACBDD3825ECB4480026705B /* ReaderPostServiceRemote+RelatedPostsTests.swift in Sources */, @@ -3487,6 +3497,7 @@ 74B335D81F06F1CA0053A184 /* MockWordPressComRestApi.swift in Sources */, 08C7493E2A45EA11000DA0E2 /* IPLocationRemoteTests.swift in Sources */, 32AF21E3236DEB3C001C6502 /* PostServiceRemoteRESTAutosaveTests.swift in Sources */, + 3FD634FB2BC3AE6C00CEDF5E /* Bundle+SPMSupport.swift in Sources */, 3236F79A24AE406D0088E8F3 /* ReaderTopicServiceRemote+InterestsTests.swift in Sources */, FEE4EF5B27302317003CDA3C /* CommentServiceRemoteREST+APIv2Tests.swift in Sources */, 803DE81128FFA9C4007D4E9C /* RemoteConfigRemoteTests.swift in Sources */, @@ -3554,6 +3565,7 @@ 74A44DD51F13C6D8006CD8F4 /* PushAuthenticationServiceRemoteTests.swift in Sources */, 4AE278482B2FBF1100E4D9B1 /* HTTPBodyEncodingTests.swift in Sources */, 731BA83621DECD61000FDFCD /* SiteCreationRequestEncodingTests.swift in Sources */, + 3FD634FA2BC3AE6800CEDF5E /* AppTransportSecuritySettingsTests.swift in Sources */, 7EC60EBE22DC4F9000FB0336 /* EditorServiceRemoteTests.swift in Sources */, 931924241F1662FA0069CBCC /* JSONLoader.swift in Sources */, E1787DB2200E5690004CB3AF /* TimeZoneServiceRemoteTests.swift in Sources */,