summaryrefslogtreecommitdiff
path: root/qa/qa/resource/user_gpg.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/resource/user_gpg.rb')
-rw-r--r--qa/qa/resource/user_gpg.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/qa/qa/resource/user_gpg.rb b/qa/qa/resource/user_gpg.rb
new file mode 100644
index 00000000000..25d74ad8ce5
--- /dev/null
+++ b/qa/qa/resource/user_gpg.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+module QA
+ module Resource
+ class UserGPG < Base
+ attr_accessor :id, :gpg
+ attr_reader :key_id
+
+ def initialize
+ @gpg = Runtime::GPG.new
+ @key_id = @gpg.key_id
+ end
+
+ def fabricate_via_api!
+ super
+ @id = self.api_response[:id]
+ rescue ResourceFabricationFailedError => error
+ if error.message.include? 'has already been taken'
+ self
+ else
+ raise ResourceFabricationFailedError error
+ end
+ end
+
+ def resource_web_url(resource)
+ super
+ rescue ResourceURLMissingError
+ # this particular resource does not expose a web_url property
+ end
+
+ def api_get_path
+ "/user/gpg_keys/#{@id}"
+ end
+
+ def api_post_path
+ '/user/gpg_keys'
+ end
+
+ def api_post_body
+ {
+ key: @gpg.key
+ }
+ end
+ end
+ end
+end