Add UI smoke tests for Invidious behind HTTP Basic Auth

Three end-to-end specs that exercise the new basic-auth flows against a
real Invidious instance fronted by an nginx reverse proxy:

  1. add flow: types the URL, hits Detect, fills the basic-auth fields
     when the basicAuthRequired UI state appears, taps Retry Detection,
     and confirms the instance lands in the Sources list.

  2. state assertion: types a URL, taps Detect, and verifies the form
     transitions into the basicAuthRequired state (Retry Detection button
     present, no detected type) when no credentials were supplied.

  3. proxied login: ensures the instance exists, then drives the standard
     Invidious login flow with the proxied account credentials. Confirms
     the SID Cookie auth coexists with the per-client Authorization
     header on the basic-auth-aware HTTPClient.

Test infrastructure additions:

- spec/ui/support/config.rb: env-driven accessors for the basic-auth URL
  and proxied-account credentials. No secrets committed.

- spec/ui/support/instance_setup.rb: helpers
  add_invidious_with_basic_auth, remove_and_add_invidious_with_basic_auth,
  find_basic_auth_text_fields (mirroring find_auth_text_fields), and
  fill_field for tapping a discovered field by frame and typing into it.

All three specs skip cleanly when the relevant env vars are not set.
This commit is contained in:
Arkadiusz Fal
2026-04-06 22:12:10 +02:00
parent eefd49f743
commit 56cd60a8ba
3 changed files with 319 additions and 0 deletions

View File

@@ -112,6 +112,46 @@ module UITest
invidious_email && invidious_password
end
# Invidious URL for an instance fronted by HTTP Basic Auth (configurable via env)
def invidious_basic_auth_url
ENV.fetch('INVIDIOUS_BASIC_AUTH_URL', 'https://i03.s.yattee.stream')
end
# Extract host from the basic-auth Invidious URL
def invidious_basic_auth_host
URI.parse(invidious_basic_auth_url).host
end
# HTTP Basic Auth username for the proxy in front of the Invidious instance
def invidious_basic_auth_username
ENV.fetch('INVIDIOUS_BASIC_AUTH_USERNAME', nil)
end
# HTTP Basic Auth password for the proxy in front of the Invidious instance
def invidious_basic_auth_password
ENV.fetch('INVIDIOUS_BASIC_AUTH_PASSWORD', nil)
end
# Whether the basic-auth proxy credentials for Invidious are configured
def invidious_basic_auth_credentials?
invidious_basic_auth_username && invidious_basic_auth_password
end
# Invidious account email/username behind the basic-auth proxy
def invidious_proxied_email
ENV.fetch('INVIDIOUS_PROXIED_EMAIL', nil)
end
# Invidious account password behind the basic-auth proxy
def invidious_proxied_password
ENV.fetch('INVIDIOUS_PROXIED_PASSWORD', nil)
end
# Whether the proxied Invidious account credentials are configured
def invidious_proxied_credentials?
invidious_proxied_email && invidious_proxied_password
end
# Piped URL for testing (configurable via env)
def piped_url
ENV.fetch('PIPED_URL', 'https://pipedapi.home.arekf.net')