mozilla / geckodriver

WebDriver for Firefox
https://firefox-source-docs.mozilla.org/testing/geckodriver/
Mozilla Public License 2.0
7.18k stars 1.52k forks source link

Cannot create virtual authenticator; response is 405 HTTP method not allowed #2187

Closed ecbypi closed 3 months ago

ecbypi commented 3 months ago

I get this error when testing using Capybara in a Rails app, but I am able to reproduce the error (405 HTTP method not allowed) when starting geckodriver manually and running curl commands.

When using --log trace to start geckodriver, nothing is logged on the request to create the virtual authenticator.

Please let me know if anything is missing.

System

Testcase

geckodriver -b /Applications/Firefox.app/Contents/MacOS/firefox --log trace
# => 1720726945422   geckodriver     INFO    Listening on 127.0.0.1:4444
curl -X POST -d @options.json -H 'Content-Type: application/json' 127.0.0.1:4444/session
# => {"value":{"sessionId":"1bf86513-30fb-420a-80a0-ae3a97032178" ...

curl -X POST -vvv -d @authenticator.json -H 'Content-Type: application/json' 127.0.0.1:4444/session/1bf86513-30fb-420a-80a0-ae3a97032178/webauthn/authenticator
* Uses proxy env variable no_proxy == '*'
*   Trying 127.0.0.1:4444...
* Connected to 127.0.0.1 (127.0.0.1) port 4444
> POST /session/06161a48-9ecd-4e18-986f-140d5af08610/webauthn/authenticator HTTP/1.1
> Host: 127.0.0.1:4444
> User-Agent: curl/8.6.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 132
>
< HTTP/1.1 405 Method Not Allowed
< content-type: text/plain; charset=utf-8
< content-length: 23
< date: Thu, 11 Jul 2024 19:53:12 GMT
<
* Connection #0 to host 127.0.0.1 left intact
HTTP method not allowed

options.json:

{
  "capabilities": {
    "alwaysMatch": {
      "acceptInsecureCerts": true,
      "browserName": "firefox",
      "moz:firefoxOptions": {
        "args": [
          "-headless"
        ],
        "prefs": {
          "remote.active-protocols": 3
        }
      },
      "moz:debuggerAddress": true
    }
  }
}

authenticator.json:

{
  "protocol": "ctap2",
  "transport": "usb",
  "hasResidentKey": true,
  "hasUserVerification": true,
  "isUserConsenting": true,
  "isUserVerified": true
}

Stacktrace

Trace-level log

1720727397614   geckodriver INFO    Listening on 127.0.0.1:4444
1720727411868   webdriver::server   DEBUG   -> POST /session {"capabilities":{"alwaysMatch":{"acceptInsecureCerts":true,"browserName":"firefox","moz:firefoxOptions":{"args":["-headless"],"prefs":{"remote.active-protocols":3}},"moz:debuggerAddress":true}}}
1720727411868   geckodriver::capabilities   DEBUG   Trying to read firefox version from ini files
1720727411870   geckodriver::capabilities   DEBUG   Found version 128.0
1720727411877   mozrunner::runner   INFO    Running command: MOZ_CRASHREPORTER="1" MOZ_CRASHREPORTER_NO_REPORT="1" MOZ_CRASHREPORTER_SHUTDOWN="1" MOZ_NO_REMOTE="1" "/App ... s" "localhost" "-foreground" "-no-remote" "-profile" "/var/folders/nx/8zd7ck8914g_xc0hdgpycf8w0000gn/T/rust_mozprofileWxKoBe"
1720727411878   geckodriver::marionette DEBUG   Waiting 60s to connect to browser on 127.0.0.1
1720727411878   geckodriver::browser    TRACE   Failed to open /var/folders/nx/8zd7ck8914g_xc0hdgpycf8w0000gn/T/rust_mozprofileWxKoBe/MarionetteActivePort
1720727411878   geckodriver::marionette TRACE   Retrying in 100ms
1720727411983   geckodriver::browser    TRACE   Failed to open /var/folders/nx/8zd7ck8914g_xc0hdgpycf8w0000gn/T/rust_mozprofileWxKoBe/MarionetteActivePort
1720727411983   geckodriver::marionette TRACE   Retrying in 100ms
console.warn: services.settings: Ignoring preference override of remote settings server
console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
1720727412088   geckodriver::browser    TRACE   Failed to open /var/folders/nx/8zd7ck8914g_xc0hdgpycf8w0000gn/T/rust_mozprofileWxKoBe/MarionetteActivePort
1720727412088   geckodriver::marionette TRACE   Retrying in 100ms
1720727412156   RemoteAgent DEBUG   Setting recommended pref apz.content_response_timeout to 60000
1720727412156   RemoteAgent DEBUG   Setting recommended pref browser.contentblocking.introCount to 99
1720727412156   RemoteAgent DEBUG   Setting recommended pref browser.download.panel.shown to true
1720727412156   RemoteAgent DEBUG   Setting recommended pref browser.newtabpage.activity-stream.discoverystream.region-weather-config to 
1720727412156   RemoteAgent DEBUG   Setting recommended pref browser.newtabpage.activity-stream.newtabWallpapers.enabled to false
1720727412156   RemoteAgent DEBUG   Setting recommended pref browser.newtabpage.activity-stream.showSponsoredTopSites to false
1720727412156   RemoteAgent DEBUG   Setting recommended pref browser.newtabpage.enabled to false
1720727412156   RemoteAgent DEBUG   Setting recommended pref browser.pagethumbnails.capturing_disabled to true
1720727412156   RemoteAgent DEBUG   Setting recommended pref browser.region.network.url to 
1720727412156   RemoteAgent DEBUG   Setting recommended pref browser.safebrowsing.blockedURIs.enabled to false
1720727412157   RemoteAgent DEBUG   Setting recommended pref browser.safebrowsing.downloads.enabled to false
1720727412157   RemoteAgent DEBUG   Setting recommended pref browser.safebrowsing.malware.enabled to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref browser.safebrowsing.phishing.enabled to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref browser.search.update to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref browser.startup.couldRestoreSession.count to -1
1720727412158   RemoteAgent DEBUG   Setting recommended pref browser.tabs.remote.unloadDelayMs to 0
1720727412158   RemoteAgent DEBUG   Setting recommended pref browser.tabs.unloadOnLowMemory to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref browser.tabs.warnOnClose to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref browser.tabs.warnOnCloseOtherTabs to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref browser.tabs.warnOnOpen to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref browser.toolbars.bookmarks.visibility to never
1720727412158   RemoteAgent DEBUG   Setting recommended pref browser.topsites.contile.enabled to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref browser.usedOnWindows10.introURL to 
1720727412158   RemoteAgent DEBUG   Setting recommended pref browser.urlbar.merino.endpointURL to 
1720727412158   RemoteAgent DEBUG   Setting recommended pref browser.urlbar.suggest.searches to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref datareporting.policy.dataSubmissionPolicyAccepted to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref dom.disable_open_during_load to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref dom.file.createInChild to true
1720727412158   RemoteAgent DEBUG   Setting recommended pref dom.input_events.security.minNumTicks to 0
1720727412158   RemoteAgent DEBUG   Setting recommended pref dom.input_events.security.minTimeElapsedInMS to 0
1720727412158   RemoteAgent DEBUG   Setting recommended pref dom.max_chrome_script_run_time to 0
1720727412158   RemoteAgent DEBUG   Setting recommended pref dom.max_script_run_time to 0
1720727412158   RemoteAgent DEBUG   Setting recommended pref dom.navigation.locationChangeRateLimit.count to 0
1720727412158   RemoteAgent DEBUG   Setting recommended pref dom.push.connection.enabled to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref dom.screenorientation.allow-lock to true
1720727412158   RemoteAgent DEBUG   Setting recommended pref dom.successive_dialog_time_limit to 0
1720727412158   RemoteAgent DEBUG   Setting recommended pref extensions.getAddons.cache.enabled to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref extensions.getAddons.discovery.api_url to data:, 
1720727412158   RemoteAgent DEBUG   Setting recommended pref extensions.blocklist.detailsURL to http://%(server)s/extensions-dummy/blocklistDetailsURL
1720727412158   RemoteAgent DEBUG   Setting recommended pref extensions.blocklist.itemURL to http://%(server)s/extensions-dummy/blocklistItemURL
1720727412158   RemoteAgent DEBUG   Setting recommended pref extensions.hotfix.url to http://%(server)s/extensions-dummy/hotfixURL
1720727412158   RemoteAgent DEBUG   Setting recommended pref extensions.systemAddon.update.url to http://%(server)s/dummy-system-addons.xml
1720727412158   RemoteAgent DEBUG   Setting recommended pref extensions.update.background.url to http://%(server)s/extensions-dummy/updateBackgroundURL
1720727412158   RemoteAgent DEBUG   Setting recommended pref extensions.update.url to http://%(server)s/extensions-dummy/updateURL
1720727412158   RemoteAgent DEBUG   Setting recommended pref extensions.getAddons.get.url to http://%(server)s/extensions-dummy/repositoryGetURL
1720727412158   RemoteAgent DEBUG   Setting recommended pref extensions.getAddons.search.browseURL to http://%(server)s/extensions-dummy/repositoryBrowseURL
1720727412158   RemoteAgent DEBUG   Setting recommended pref geo.provider.network.url to 
1720727412158   RemoteAgent DEBUG   Setting recommended pref identity.fxaccounts.auth.uri to https://{server}/dummy/fxa
1720727412158   RemoteAgent DEBUG   Setting recommended pref network.connectivity-service.enabled to false
1720727412158   RemoteAgent DEBUG   Setting recommended pref network.http.phishy-userpass-length to 255
1720727412159   RemoteAgent DEBUG   Setting recommended pref network.http.prompt-temp-redirect to false
1720727412159   RemoteAgent DEBUG   Setting recommended pref privacy.trackingprotection.enabled to false
1720727412159   RemoteAgent DEBUG   Setting recommended pref remote.prefs.recommended.applied to true
1720727412159   RemoteAgent DEBUG   Setting recommended pref security.fileuri.strict_origin_policy to false
1720727412159   RemoteAgent DEBUG   Setting recommended pref security.notification_enable_delay to 0
1720727412159   RemoteAgent DEBUG   Setting recommended pref security.remote_settings.intermediates.enabled to false
1720727412159   RemoteAgent DEBUG   Setting recommended pref signon.autofillForms to false
1720727412159   RemoteAgent DEBUG   Setting recommended pref signon.rememberSignons to false
1720727412159   RemoteAgent DEBUG   Setting recommended pref toolkit.telemetry.server to https://%(server)s/telemetry-dummy/
1720727412159   RemoteAgent DEBUG   Setting recommended pref widget.windows.window_occlusion_tracking.enabled to false
1720727412159   RemoteAgent DEBUG   WebDriver BiDi enabled
1720727412159   RemoteAgent DEBUG   CDP enabled
1720727412160   Marionette  INFO    Marionette enabled
1720727412190   geckodriver::browser    TRACE   Failed to open /var/folders/nx/8zd7ck8914g_xc0hdgpycf8w0000gn/T/rust_mozprofileWxKoBe/MarionetteActivePort
1720727412190   geckodriver::marionette TRACE   Retrying in 100ms
1720727412293   Marionette  TRACE   Received observer notification final-ui-startup
1720727412294   RemoteAgent TRACE   Received observer notification final-ui-startup
1720727412295   geckodriver::browser    TRACE   Failed to open /var/folders/nx/8zd7ck8914g_xc0hdgpycf8w0000gn/T/rust_mozprofileWxKoBe/MarionetteActivePort
1720727412295   geckodriver::marionette TRACE   Retrying in 100ms
console.error: "Warning: unrecognized command line flag" "-remote-allow-hosts"
1720727412361   Marionette  INFO    Listening on port 57612
1720727412362   Marionette  DEBUG   Marionette is listening
1720727412368   RemoteAgent TRACE   Available local IP addresses: 127.0.0.1, [::1]

!!! could not start server on port 9222: [Exception... "Component returned failure code: 0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE) [nsIServerSocket.init]"  nsresult: "0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE)"  location: "JS frame :: chrome://remote/content/server/httpd.sys.mjs :: _start :: line 556"  data: no]

1720727412371   RemoteAgent ERROR   Unable to stop listener: [Exception... "Unexpected error"  nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame :: chrome://remote/content/server/httpd.sys.mjs :: stop :: line 610"  data: no] Stack trace: stop()@httpd.sys.mjs:610
#stop()@RemoteAgent.sys.mjs:353
1720727412372   RemoteAgent ERROR   Unable to start remote agent: : [Exception... "Component is not available"  nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame :: chrome://remote/content/server/httpd.sys.mjs :: _start :: line 601"  data: no] Stack trace: _start()@httpd.sys.mjs:601
#listen()@RemoteAgent.sys.mjs:272
Read port: 57612
1720727412446   Marionette  DEBUG   Accepted connection 0 from 127.0.0.1:57613
1720727412458   geckodriver::marionette DEBUG   Connection to Marionette established on 127.0.0.1:57612.
1720727412526   Marionette  DEBUG   0 -> [0,1,"WebDriver:NewSession",{"acceptInsecureCerts":true,"browserName":"firefox"}]
1720727412528   RemoteAgent WARN    TLS certificate errors will be ignored for this session
1720727412528   Marionette  DEBUG   Waiting for initial application window
[GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt
1720727413160   Marionette  TRACE   Received observer notification browser-idle-startup-tasks-finished
1720727413160   RemoteAgent TRACE   Received observer notification browser-idle-startup-tasks-finished
1720727413162   RemoteAgent TRACE   [9] ProgressListener Start: expectNavigation=false resolveWhenStarted=false unloadTimeout=5000 waitForExplicitStart=false
1720727413162   RemoteAgent TRACE   [9] ProgressListener Setting unload timer (5000ms)
1720727413162   RemoteAgent TRACE   [9] Wait for initial navigation: isInitial=false, isLoadingDocument=false
1720727413162   RemoteAgent TRACE   [9] Document already finished loading: about:blank
1720727413162   RemoteAgent TRACE   [9] ProgressListener Stop: has error=false url=about:blank
1720727413169   Marionette  DEBUG   0 <- [1,1,null,{"sessionId":"3f63996c-5a1f-4d09-8d15-c0f1d0d3b112","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"128.0","platformName":"mac","unhandledPromptBehavior":"dismiss and notify","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0","moz:buildID":"20240704121409","moz:headless":true,"moz:platformVersion":"23.5.0","moz:processID":14256,"moz:profile":"/var/folders/nx/8zd7ck8914g_xc0hdgpycf8w0000gn/T/rust_mozprofileWxKoBe","moz:shutdownTimeout":60000,"pageLoadStrategy":"normal","timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"setWindowRect":true,"strictFileInteractability":false,"moz:accessibilityChecks":false,"moz:debuggerAddress":"127.0.0.1:9222","moz:webdriverClick":true,"moz:windowless":false,"proxy":{}}}]
1720727413172   webdriver::server   DEBUG   <- 200 OK {"value":{"sessionId":"3f63996c-5a1f-4d09-8d15-c0f1d0d3b112","capabilities":{"acceptInsecureCerts":true,"browserNam ... r":"dismiss and notify","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0"}}}
whimboo commented 3 months ago

Duplicate of issue #2174.