對於我們對Drupal網站的自動化測試,我們使用Behat測試腳本。在我們的本地開發機器上,我們使用由Acquia Devdesktop創建的自簽名SSL證書。使用Behat在不同瀏覽器中運行測試是沒有問題的,因爲您可以在瀏覽器中信任該證書。但是對於沒有打開瀏覽器的REST界面來說,這是另一回事。 Behat將不接受自簽名證書,因爲它是「不安全的」。Behat硒測試信任自簽名SSL證書
當運行REST測試,這是錯誤,我們得到:
捲曲錯誤60:SSL證書的問題:自簽名證書(見http://curl.haxx.se/libcurl/c/libcurl-errors.html)(GuzzleHttp \異常\ RequestException)
使用測試用例本身沒有錯,因爲它在我們啓用SSL證書之前就已經工作了。我們嘗試使用文檔和其他tickets中的選項編輯配置.yml文件,但沒有運氣。
有沒有一種方法來信任REST接口測試的自簽名證書?如果您需要更多信息,請告訴我。
編輯:增加了YML配置和composer.json文件
//composer.json
{
"require": {
"drupal/drupal-extension": "~3.0",
"emuse/behat-html-formatter": "dev-master",
"behatch/contexts": "*",
"guzzlehttp/guzzle": "dev-master",
"behat/mink-goutte-driver": "dev-master"
},
"config": {
"bin-dir": "bin/"
}
}
注意我刪除了我的網址,從下面的YML文件。
default:
suites:
default:
contexts:
- FeatureContextDrupal
- behatch:browser
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\DrushContext
- Drupal\DrupalExtension\Context\MessageContext
- behatch:debug
- behatch:system
- behatch:json
- behatch:table
- behatch:rest
- behatch:xml
formatters:
html:
output_path: %paths.base%/build/html/behat
extensions:
Sanpi\Behatch\Extension: ~
emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
name: html
Behat\MinkExtension:
goutte:
guzzle_parameters:
verify: false
ssl.certificate_authority: false
selenium2:
wd_host: http://localhost:4444/wd/hub
base_url: "https://myurl.devcloud.acquia-sites.com/"
Drupal\DrupalExtension:
blackbox: ~
api_driver: 'drupal'
drush:
alias: 'ns-test'
drupal:
drupal_root: '/var/www/html/utcfs.dev/docroot'
chrome:
extensions:
Behat\MinkExtension:
selenium2:
browser: chrome
capabilities: { "browser": "chrome", "browserName": "chrome", "version": "*", "browserVersion": "*" }
iexplore:
extensions:
Behat\MinkExtension:
selenium2:
browser: internet explorer
capabilities: { "browser": "internet explorer", "browserName": "internet explorer", "version": "*", "browserVersion": "*" }
我用同樣的貝哈特配置,但刪除的Drupal相關的部分,並用「verify:false」和「verify:true」對https://self-signed.badssl.com/進行測試,如果這是真的,它給出了相同的錯誤,但是當我切換到假時,它並沒有失敗。我也從你的composer.json安裝了軟件包,你有沒有機會分享你正在使用的測試用例呢? – seartun