我正在写一本厨师食谱,除其他外,还会添加一些防火墙规则。但在我这样做之前,我需要为它编写一个测试。那就是我被困住的地方!
我需要的是Serverspec / Rspec代码,用于验证无法通过端口1234发送数据,即使服务器上的某些内容正在侦听该端口。
我该如何编写该测试?
答案 0 :(得分:0)
在@Tensibai的评论中找到答案
describe host('localhost') do
before do
@server = TCPServer.open 1234
end
it { should_not be_reachable.with(port: 1234, proto: :tcp) }
after do
@server.close
end
end