Chef infra 非核心资源的chefspec测试
谁能告诉我如何为下面的配方代码编写chefspec测试Chef infra 非核心资源的chefspec测试,chef-infra,chefspec,Chef Infra,Chefspec,谁能告诉我如何为下面的配方代码编写chefspec测试 {'tomcat_exec_t' => '/apps/.*/bin(/.*)?', 'tomcat_unit_file_t' => '/usr/lib/systemd/system/tomcat@.*.service', 'tomcat_cache_t' => '/apps/.*/temp(/.*)?', 'tomcat_cache_t' => '/apps/.*/work(/.*)?', 'et
{'tomcat_exec_t' => '/apps/.*/bin(/.*)?',
'tomcat_unit_file_t' => '/usr/lib/systemd/system/tomcat@.*.service',
'tomcat_cache_t' => '/apps/.*/temp(/.*)?',
'tomcat_cache_t' => '/apps/.*/work(/.*)?',
'etc_t' => '/apps/.*/conf(/.*)?',
'tomcat_log_t' => '/apps/.*/logs(/.*)?',
'tomcat_var_run_t' => '/apps/.*/logs/tomcat.pid',
'lib_t' => '/apps/.*/lib(/.*)?',
'tomcat_var_lib_t' => '/apps/.*/webapps(/.*)?'}.each do |sc, f|
selinux_policy_fcontext f do
secontext sc
end
end
我已经尝试了以下几种方法,但我想这是失败的,因为执行是由selinux_策略食谱执行的
expect(chef_run).to run_execute('selinux-fcontext-tomcat_exec_t-addormodify')
end
由于未定义任何方法,因此此操作失败:
expect(chef_run).to create_selinux-fcontext('selinux-fcontext-tomcat_exec_t-addormodify').with(
fspec: '/apps/.*/bin(/.*)?',
secontext: 'fcontext'
)
所以我不确定还能做些什么
任何帮助都将不胜感激
谢谢
Edward您可能需要编写自己的
匹配程序,具体取决于selinux烹饪书是否为您提供了这些程序。签入libraries目录
无论哪种情况,你都会想要
expect(chef_run).to create_selinux_policy_fcontext('selinux-fcontext-tomcat_exec_t-addormodify').with(
fspec: '/apps/.*/bin(/.*)?',
secontext: 'fcontext'
end
我假设默认操作是create
,否则您将用适当的操作替换create
,您可能需要编写自己的匹配器,具体取决于selinux cookbook是否为您提供了这些匹配器。签入libraries目录
无论哪种情况,你都会想要
expect(chef_run).to create_selinux_policy_fcontext('selinux-fcontext-tomcat_exec_t-addormodify').with(
fspec: '/apps/.*/bin(/.*)?',
secontext: 'fcontext'
end
我假设默认操作是create
,否则您将用适当的操作替换create
谢谢Tejay,我刚刚意识到:)谢谢Tejay,我刚刚意识到:)