summaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2018-01-19 14:11:24 +0100
committerAzul <azul@riseup.net>2018-01-19 14:11:24 +0100
commit54653f75cf44890310a06c3a8a6be59625629d2a (patch)
tree3a1c851033c46e1a140de3e3b5a17ad4b7f2647e /features
parentb8ba4f27a82868e0b3338b4af761f7c44226e729 (diff)
API: implement deleting keys through new keys api
Diffstat (limited to 'features')
-rw-r--r--features/2/keys.feature89
-rw-r--r--features/step_definitions/key_steps.rb6
2 files changed, 91 insertions, 4 deletions
diff --git a/features/2/keys.feature b/features/2/keys.feature
index cc87da0..83e70e7 100644
--- a/features/2/keys.feature
+++ b/features/2/keys.feature
@@ -114,6 +114,19 @@ Feature: Handle current users collection of keys
}
"""
+ Scenario: Publishing an empty key fails
+ When I send a POST request to "2/keys" with the following:
+ """
+ {}
+ """
+ Then the response status should be "422"
+ And the response should be:
+ """
+ {
+ "error": "param is missing or the value is empty: type"
+ }
+ """
+
Scenario: Updating an existing key
Given I have published a "openpgp" key
When I send a PATCH request to "2/keys/openpgp" with the following:
@@ -127,6 +140,24 @@ Feature: Handle current users collection of keys
Then the response status should be "204"
And I should have published a "openpgp" key with value "QWER"
+ Scenario: Updating a missing key raises
+ When I send a PATCH request to "2/keys/openpgp" with the following:
+ """
+ {
+ "type": "openpgp",
+ "value": "QWER",
+ "rev": "DUMMY_REV"
+ }
+ """
+ Then the response status should be "404"
+ And the response should be:
+ """
+ {
+ "error": "no such key: openpgp"
+ }
+ """
+ And I should not have published a "openpgp" key
+
Scenario: Updating an existing key require revision
Given I have published a "openpgp" key
When I send a PATCH request to "2/keys/openpgp" with the following:
@@ -162,15 +193,65 @@ Feature: Handle current users collection of keys
}
"""
- Scenario: Publishing an empty key fails
- When I send a POST request to "2/keys" with the following:
+ Scenario: Deleting an existing key
+ Given I have published a "openpgp" key
+ When I send a DELETE request to "2/keys/openpgp" with the following:
"""
- {}
+ {
+ "type": "openpgp",
+ "rev": "DUMMY_REV"
+ }
+ """
+ Then the response status should be "204"
+ And I should not have published a "openpgp" key
+
+ Scenario: Deleting a missing key raises
+ When I send a DELETE request to "2/keys/openpgp" with the following:
+ """
+ {
+ "type": "openpgp",
+ "rev": "DUMMY_REV"
+ }
+ """
+ Then the response status should be "404"
+ And the response should be:
+ """
+ {
+ "error": "no such key: openpgp"
+ }
+ """
+
+ Scenario: Deleting an existing key require revision
+ Given I have published a "openpgp" key
+ When I send a DELETE request to "2/keys/openpgp" with the following:
+ """
+ {
+ "type": "openpgp"
+ }
"""
Then the response status should be "422"
And the response should be:
"""
{
- "error": "param is missing or the value is empty: type"
+ "error": "param is missing or the value is empty: rev"
+ }
+ """
+ And I should have published a "openpgp" key
+
+ Scenario: Deleting an existing key require right revision
+ Given I have published a "openpgp" key
+ When I send a DELETE request to "2/keys/openpgp" with the following:
+ """
+ {
+ "type": "openpgp",
+ "rev": "WRONG_REV"
}
"""
+ Then the response status should be "422"
+ And the response should be:
+ """
+ {
+ "error": "wrong revision: WRONG_REV"
+ }
+ """
+ And I should have published a "openpgp" key
diff --git a/features/step_definitions/key_steps.rb b/features/step_definitions/key_steps.rb
index 70a13bd..3d5e015 100644
--- a/features/step_definitions/key_steps.rb
+++ b/features/step_definitions/key_steps.rb
@@ -18,3 +18,9 @@ Then /^I should have published an? "([^"]*)" key(?: with value "([^"]*)")?$/ do
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