conjur
conjur copied to clipboard
Remove duplication in cucumber Before hooks
Currently the code to reset the DB between cucumber test runs is repeated in four of the different profiles. We should figure out the correct, best-practice cucumber way of sharing such code and then remove the duplication.
The code in question looks like this:
Before do
@user_index = 0
@host_index = 0
Role.truncate(cascade: true)
Secret.truncate
Credentials.truncate
Slosilo.each do |k, _|
unless %w(authn:rspec authn:cucumber).member?(k)
Slosilo.send(:keystore).adapter.model[k].delete
end
end
Account.find_or_create_accounts_resource
admin_role = Role.create(role_id: "cucumber:user:admin")
creds = Credentials.new(role: admin_role)
# TODO: Replace this hack with a refactoring of policy/api/authenticators to
# share this code, and to it the api way (probably)
creds.password = 'SEcret12!!!!'
creds.save(raise_on_save_failure: true)
end
https://github.com/cyberark/conjur/blob/e92ae1900411b45a3efdc2e475ba5bc396b7b12e/cucumber/_authenticators_common/features/support/hooks.rb#L11