Squish 测试中心作为后端服务
本节展示了如何以 Windows 服务的方式启动 Squish 测试中心,如何将 Squish 测试中心集成到现有的 Web 服务中,以及如何设置和/或启用 Squish 测试中心的 HTTPS 访问。
在 config 目录中的 application.ini 文件中配置 Squish 测试中心的 TCP 监听端口。选项是 ListenPort。其值也可以是一个 Unix 域套接字。例如,ListenPort=unix:/tmp/testcenter。
Squish 测试中心作为 Windows 服务
要将以 Windows 服务的方式启动 Squish 测试中心,请在命令行中运行以下命令安装服务:
bin\testcenter service-install
注意:这可能会因为需要提升权限而无法无错误地工作。
现在您可以从 Windows 的 服务 面板中启动服务。如果服务启动失败,Squish 测试中心会在 Windows 的事件日志中输出信息。
您可以从 服务 面板停止 Squish 测试中心服务。
要卸载服务,请输入以下命令
bin\testcenter service-uninstall
Apache 反向代理示例
以下是一个使用 Apache Web 服务器进行反向代理的示例。必须启用 mod_proxy 和 mod_proxy_http 模块。
cd mods-enabled/ ln -s ../mods-available/proxy.load . ln -s ../mods-available/proxy_http.load . ln -s ../mods-available/proxy_wstunnel.load . ln -s ../mods-available/rewrite.load .
以下 VirtualHost 配置将请求转发到同一主机上 Squish 测试中心默认的端口 8800
<VirtualHost _default_:443>
ProxyPass / https://:8800/ connectiontimeout=600 timeout=600
ProxyPassReverse / https://:8800/
ProxyPreserveHost On
ProxyRequests Off
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://:8800/$1" [P,L]
SSLEngine on
SSLCertificateFile your-crt-file.crt
SSLCertificateKeyFile your-key-file.key
</VirtualHost>为了为 Squish 测试中心提供相对路径,如位于 /jellyfish/ 之下,需要调整 Web 应用的 URL。在 application.ini 中,将 TestCenter 组中的 UrlRootPath 选项设置为 /jellyfish/。下面的虚拟主机配置通过重写路径,将请求转发到同一主机上 Squish 测试中心的默认端口 8800。
<VirtualHost *>
ProxyPass /jellyfish/ https://:8800/
<Location /jellyfish/>
ProxyPassReverse /
</Location>
ProxyRequests Off
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/jellyfish/(.*) "ws://:8800/$1" [P,L]
</VirtualHost>使用 Hitch TLS 代理
下面是 Hitch 代理服务器的配置,它可以作为 Squish 测试中心的 SSL 前端。
frontend = {
host = "*"
port = "443"
}
backend = "[127.0.0.1]:8800"
pem-file = "your-pem-file.pem"认证代理设置
Squish 测试中心可以配置为将认证任务交给认证代理。Squish 测试中心的认证支持是为 OAuth2 Proxy 开发的。即使使用认证代理,用户也必须在 Squish 测试中心创建账户,但他们不需要输入 Squish 测试中心的凭据。
警告:使用认证代理时,请确保您的 Squish 测试中心实例的 /login 终端只能通过认证代理访问。
要激活认证代理支持,编辑位于 /testcenter/config 的 application.ini 文件。将 Enable.Proxy 设置为 true。使用 Header.Name 设置来指定认证代理发送的哪个 HTTP Header 包含已认证用户的电子邮件地址。在下面的示例中,它是 X-Forwarded-User。
注意:认证代理必须转发用户电子邮件地址,而不是账户名称或别名,因为 Squish 测试中心只知道电子邮件地址。
[ProxyAuth] # When enabled login is limited to requests coming from the authentication proxy Enable.Proxy=true # HTTP header name set by the proxy that will contain the E-Mail of the # authenticated user Header.Name=X-Forwarded-User # Use this to specify the logout URL of your authentication proxy. If the # authentication proxy support is enabled and Logout.Url is not set, then # the logout link in the user menu is hidden, as the default logout procedure # is incompatible with authentication proxies # Logout.Url=http://auth.company.com/oauth2/sign_out
使用认证代理时,Squish 测试中心的默认注销机制将不起作用。因此,除非您指定 Logout.Url 设置,该设置应指向您使用的认证代理的注销终端,否则注销选项将从用户菜单中隐藏。
©2023 Qt 公司有限公司。本文件内包含的文档贡献者的版权。
此处提供的文档根据自由软件基金会发布的 GNU 自由文档许可证版本 1.3 的条款进行许可。
Qt 和相应的标志是芬兰和/或世界其他国家的 Qt 公司的商标。所有其他商标均为其各自所有者的财产。