summaryrefslogtreecommitdiff
path: root/features/step_definitions
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2018-01-28 08:37:45 -0800
committerazul <azul@riseup.net>2018-01-28 08:37:45 -0800
commit19606ec31d7a1606b5e9fc4df2440a6b470e9d97 (patch)
tree3a1c851033c46e1a140de3e3b5a17ad4b7f2647e /features/step_definitions
parentf77e48b1ffdc2350c454ced2fe1eba6446f7bc76 (diff)
parent54653f75cf44890310a06c3a8a6be59625629d2a (diff)
Merge branch 'feature/different-keytypes' into 'master'
initial feature description for key uploads See merge request leap/webapp!58
Diffstat (limited to 'features/step_definitions')
-rw-r--r--features/step_definitions/api_steps.rb4
-rw-r--r--features/step_definitions/key_steps.rb26
2 files changed, 28 insertions, 2 deletions
diff --git a/features/step_definitions/api_steps.rb b/features/step_definitions/api_steps.rb
index 7188694..7b73272 100644
--- a/features/step_definitions/api_steps.rb
+++ b/features/step_definitions/api_steps.rb
@@ -37,7 +37,7 @@ When /^I digest\-authenticate as the user "(.*?)" with the password "(.*?)"$/ do
digest_authorize user, pass
end
-When /^I (?:have sent|send) a (GET|POST|PUT|DELETE) request (?:for|to) "([^"]*)"(?: with the following:)?$/ do |*args|
+When /^I (?:have sent|send) a (GET|POST|PUT|DELETE|PATCH) request (?:for|to) "([^"]*)"(?: with the following:)?$/ do |*args|
request_type = args.shift
path = args.shift
input = args.shift
@@ -45,7 +45,7 @@ When /^I (?:have sent|send) a (GET|POST|PUT|DELETE) request (?:for|to) "([^"]*)"
request_opts = {method: request_type.downcase.to_sym}
unless input.nil?
- if input.class == Cucumber::Ast::Table
+ if input.class == Cucumber::MultilineArgument::DataTable
request_opts[:params] = input.rows_hash
else
request_opts[:input] = input
diff --git a/features/step_definitions/key_steps.rb b/features/step_definitions/key_steps.rb
new file mode 100644
index 0000000..3d5e015
--- /dev/null
+++ b/features/step_definitions/key_steps.rb
@@ -0,0 +1,26 @@
+Given /^I have published a "([^"]*)" key$/ do |type|
+ identity = Identity.for(@user)
+ keyring = Keyring.new(identity)
+ SecureRandom.stubs(urlsafe_base64: 'DUMMY_REV')
+ keyring.create type, 'DUMMY_KEY'
+end
+
+Given /^I have published "([^"]*)" keys$/ do |type|
+ identity = Identity.for(@user)
+ keyring = Keyring.new(identity)
+ SecureRandom.stubs(urlsafe_base64: 'DUMMY_REV')
+ keyring.create type, one: 'DUMMY_KEY', two: 'DUMMY_KEY'
+end
+
+Then /^I should have published an? "([^"]*)" key(?: with value "([^"]*)")?$/ do |type, value|
+ identity = Identity.for(@user)
+ keys = identity.keys
+ assert_includes keys.keys, type
+ assert_equal value, JSON.parse(keys[type])['value'] if value
+end
+
+Then /^I should not have published an? "([^"]*)" key$/ do |type|
+ identity = Identity.for(@user)
+ keys = identity.keys
+ refute_includes keys.keys, type
+end