@@ -17,7 +17,7 @@ class LoginTests {
1717 func testValidURL( ) async throws {
1818 let stubs = HTTPStubs ( stubs: [
1919 try HTTPStubs . stub ( url: " https://vanilla.wpmt.co/ " , with: . withApiRoot( " https://vanilla.wpmt.co/wp-json/ " ) ) ,
20- try HTTPStubs . stub ( url: " https://vanilla.wpmt.co/wp-json/ " , with: . vanillaApiRoot ( siteUrl : " https:// vanilla.wpmt.co " ) )
20+ try HTTPStubs . stub ( url: " https://vanilla.wpmt.co/wp-json/ " , with: . loginMockResponse ( named : " vanilla-api-root " ) )
2121 ] )
2222 let client = WordPressLoginClient ( requestExecutor: stubs)
2323 let parsedUrl = try await client. findLoginUrl ( forSite: " https://vanilla.wpmt.co " )
@@ -59,7 +59,7 @@ class LoginTests {
5959 // The AutoStrippedHttps attempt strips the admin suffix and succeeds.
6060 let stubs = HTTPStubs ( stubs: [
6161 try HTTPStubs . stub ( url: " https://vanilla.wpmt.co/ " , with: . withApiRoot( " https://vanilla.wpmt.co/wp-json/ " ) ) ,
62- try HTTPStubs . stub ( url: " https://vanilla.wpmt.co/wp-json/ " , with: . vanillaApiRoot ( siteUrl : " https:// vanilla.wpmt.co " ) )
62+ try HTTPStubs . stub ( url: " https://vanilla.wpmt.co/wp-json/ " , with: . loginMockResponse ( named : " vanilla-api-root " ) )
6363 ] )
6464 let client = WordPressLoginClient ( requestExecutor: stubs)
6565 let parsedUrl = try await client. findLoginUrl ( forSite: provided)
@@ -72,7 +72,7 @@ class LoginTests {
7272 // AutoStrippedHttps attempt converts to https:// and succeeds.
7373 let stubs = HTTPStubs ( stubs: [
7474 try HTTPStubs . stub ( url: " https://vanilla.wpmt.co/ " , with: . withApiRoot( " https://vanilla.wpmt.co/wp-json/ " ) ) ,
75- try HTTPStubs . stub ( url: " https://vanilla.wpmt.co/wp-json/ " , with: . vanillaApiRoot ( siteUrl : " https:// vanilla.wpmt.co " ) )
75+ try HTTPStubs . stub ( url: " https://vanilla.wpmt.co/wp-json/ " , with: . loginMockResponse ( named : " vanilla-api-root " ) )
7676 ] )
7777 let client = WordPressLoginClient ( requestExecutor: stubs)
7878 let parsedUrl = try await client. findLoginUrl ( forSite: " http://vanilla.wpmt.co " )
@@ -85,7 +85,7 @@ class LoginTests {
8585 do {
8686 stubs = HTTPStubs ( stubs: [
8787 try HTTPStubs . stub ( url: " http://no-https.wpmt.co/ " , with: . withApiRoot( " http://no-https.wpmt.co/wp-json/ " ) ) ,
88- try HTTPStubs . stub ( url: " http://no-https.wpmt.co/wp-json/ " , with: . httpOnlyApiRoot ( siteUrl : " http://no-https.wpmt.co " ) )
88+ try HTTPStubs . stub ( url: " http://no-https.wpmt.co/wp-json/ " , with: . loginMockResponse ( named : " http-only-api-root " ) )
8989 ] )
9090 } catch {
9191 Issue . record ( " Failed to create stubs: \( error) " )
@@ -111,7 +111,7 @@ class LoginTests {
111111 func testHttpOnlySiteWithApplicationPasswordsEnabled( ) async throws {
112112 let stubs = HTTPStubs ( stubs: [
113113 try HTTPStubs . stub ( url: " http://no-https-with-application-passwords.wpmt.co/ " , with: . withApiRoot( " http://no-https-with-application-passwords.wpmt.co/wp-json/ " ) ) ,
114- try HTTPStubs . stub ( url: " http://no-https-with-application-passwords.wpmt.co/wp-json/ " , with: . httpOnlyWithAppPasswordsApiRoot ( siteUrl : " http://no-https -with-application -passwords.wpmt.co " ) )
114+ try HTTPStubs . stub ( url: " http://no-https-with-application-passwords.wpmt.co/wp-json/ " , with: . loginMockResponse ( named : " http-only -with-app -passwords-api-root " ) )
115115 ] )
116116 let client = WordPressLoginClient ( requestExecutor: stubs)
117117 let parsedUrl = try await client. findLoginUrl ( forSite: " http://no-https-with-application-passwords.wpmt.co " )
@@ -123,7 +123,7 @@ class LoginTests {
123123 // Homepage has no Link header, but HTML contains a <link> tag pointing to the API root
124124 let stubs = HTTPStubs ( stubs: [
125125 try HTTPStubs . stub ( url: " https://aggressive-caching.wpmt.co/ " , with: . htmlResponse( named: " homepage-with-link-tag " ) ) ,
126- try HTTPStubs . stub ( url: " https://aggressive-caching.wpmt.co/wp-json/ " , with: . vanillaApiRoot ( siteUrl : " https:// aggressive-caching.wpmt.co " ) )
126+ try HTTPStubs . stub ( url: " https://aggressive-caching.wpmt.co/wp-json/ " , with: . loginMockResponse ( named : " aggressive-caching-api-root " ) )
127127 ] )
128128 let client = WordPressLoginClient ( requestExecutor: stubs)
129129 let parsedUrl = try await client. findLoginUrl ( forSite: " https://aggressive-caching.wpmt.co " )
@@ -186,7 +186,7 @@ class LoginTests {
186186 func testWordPressSubdirectoryWithLinkHeader( ) async throws {
187187 let stubs = HTTPStubs ( stubs: [
188188 try HTTPStubs . stub ( url: " https://subdirectory.wpmt.co/index.php?link_header=true " , with: . withApiRoot( " https://subdirectory.wpmt.co/wordpress/wp-json/ " ) ) ,
189- try HTTPStubs . stub ( url: " https://subdirectory.wpmt.co/wordpress/wp-json/ " , with: . vanillaApiRoot ( siteUrl : " https:// subdirectory.wpmt.co/wordpress " ) )
189+ try HTTPStubs . stub ( url: " https://subdirectory.wpmt.co/wordpress/wp-json/ " , with: . loginMockResponse ( named : " subdirectory-api-root " ) )
190190 ] )
191191 let client = WordPressLoginClient ( requestExecutor: stubs)
192192 let parsedUrl = try await client. findLoginUrl ( forSite: " https://subdirectory.wpmt.co/index.php?link_header=true " )
@@ -198,7 +198,7 @@ class LoginTests {
198198 // Homepage has no Link header but HTML contains a <link> tag pointing to subdirectory wp-json
199199 let stubs = HTTPStubs ( stubs: [
200200 try HTTPStubs . stub ( url: " https://subdirectory.wpmt.co/index.php?link_tag=true " , with: . htmlResponse( named: " homepage-with-subdirectory-link-tag " ) ) ,
201- try HTTPStubs . stub ( url: " https://subdirectory.wpmt.co/wordpress/wp-json/ " , with: . vanillaApiRoot ( siteUrl : " https:// subdirectory.wpmt.co/wordpress " ) )
201+ try HTTPStubs . stub ( url: " https://subdirectory.wpmt.co/wordpress/wp-json/ " , with: . loginMockResponse ( named : " subdirectory-api-root " ) )
202202 ] )
203203 let client = WordPressLoginClient ( requestExecutor: stubs)
204204 let parsedUrl = try await client. findLoginUrl ( forSite: " https://subdirectory.wpmt.co/index.php?link_tag=true " )
@@ -211,7 +211,7 @@ class LoginTests {
211211 // With mocks, we simulate the final response directly on the requested URL.
212212 let stubs = HTTPStubs ( stubs: [
213213 try HTTPStubs . stub ( url: " https://subdirectory.wpmt.co/index.php?redirect=true " , with: . withApiRoot( " https://subdirectory.wpmt.co/wordpress/wp-json/ " ) ) ,
214- try HTTPStubs . stub ( url: " https://subdirectory.wpmt.co/wordpress/wp-json/ " , with: . vanillaApiRoot ( siteUrl : " https:// subdirectory.wpmt.co/wordpress " ) )
214+ try HTTPStubs . stub ( url: " https://subdirectory.wpmt.co/wordpress/wp-json/ " , with: . loginMockResponse ( named : " subdirectory-api-root " ) )
215215 ] )
216216 let client = WordPressLoginClient ( requestExecutor: stubs)
217217 let parsedUrl = try await client. findLoginUrl ( forSite: " https://subdirectory.wpmt.co/index.php?redirect=true " )
@@ -287,7 +287,7 @@ class LoginTests {
287287 func testWordPressHttpBasicWithValidCredentials( ) async throws {
288288 let stubs = HTTPStubs ( stubs: [
289289 try HTTPStubs . stub ( url: " https://basic-auth.wpmt.co/ " , with: . withApiRoot( " https://basic-auth.wpmt.co/wp-json/ " ) ) ,
290- try HTTPStubs . stub ( url: " https://basic-auth.wpmt.co/wp-json/ " , with: . vanillaApiRoot ( siteUrl : " https:// basic-auth.wpmt.co " ) )
290+ try HTTPStubs . stub ( url: " https://basic-auth.wpmt.co/wp-json/ " , with: . loginMockResponse ( named : " basic-auth-api-root " ) )
291291 ] )
292292 let valid = ApiDiscoveryAuthenticationMiddleware ( username: " test@example.com " , password: " str0ngp4ssw0rd! " )
293293
@@ -305,7 +305,7 @@ class LoginTests {
305305 // The Link header points to the custom API root
306306 let stubs = HTTPStubs ( stubs: [
307307 try HTTPStubs . stub ( url: " https://custom-rest-prefix.wpmt.co/ " , with: . withApiRoot( " https://custom-rest-prefix.wpmt.co/custom-api/ " ) ) ,
308- try HTTPStubs . stub ( url: " https://custom-rest-prefix.wpmt.co/custom-api/ " , with: . vanillaApiRoot ( siteUrl : " https:// custom-rest-prefix.wpmt.co " ) )
308+ try HTTPStubs . stub ( url: " https://custom-rest-prefix.wpmt.co/custom-api/ " , with: . loginMockResponse ( named : " custom-rest-prefix-api-root " ) )
309309 ] )
310310 let client = WordPressLoginClient ( requestExecutor: stubs)
311311 let parsedUrl = try await client. findLoginUrl ( forSite: " https://custom-rest-prefix.wpmt.co " )
0 commit comments