我希望在serverspec中为nginx重写调用创建一个测试,如下所示(它将对^/folder/file.json URL的请求重定向到@redirect_url变量):
rewrite ^/folder/file.json <%= @redirect_url %> permanent;一本我正在更新的厨师食谱。不幸的是,从我在互联网上所能找到的,它要么突显了我对nginx和serverspec术语的完全缺乏理解,要么就是你不能做到这一点。有谁能帮上忙吗?
发布于 2017-07-22 04:47:29
您可以使用Ruby的Net::HTTP直接检查响应代码
describe Net::HTTP.get_response(URI('http://localhost:port/path')) do
its(:code) { should eq '301' }
its(:msg) { should match 'Moved Permanently' }
end发布于 2017-07-21 23:25:42
使用curl命令的重定向服务规范如下所示:
redirect_url = "..."
describe command("curl -I http://example.com/folder/file.json") do
its(:stdout) { should match(%r|HTTP/1.1 301 Moved Permanently|) }
its(:stdout) { should match(%r|Location: #{Regexp.escape(redirect_url)}|) }
endhttps://stackoverflow.com/questions/45232394
复制相似问题