class Serverspec::Type::OctopusDeployUser
Public Class Methods
new(*url_and_api_key, userName)
click to toggle source
# File lib/octopus_serverspec_extensions/type/octopus_deploy_user.rb, line 11 def initialize(*url_and_api_key, userName) serverUrl, apiKey = get_octopus_creds(url_and_api_key) @name = "Octopus Deploy User Account #{userName}" @runner = Specinfra::Runner @serverUrl = serverUrl @apiKey = apiKey # is our auth info still nil? if (serverUrl.nil?) raise "'serverUrl' was not provided. Unable to connect to Octopus server to validate configuration." end if (apiKey.nil?) raise "'apiKey' was not provided. Unable to connect to Octopus server to validate configuration." end if(userName.nil?) raise "'userName' was not provided" end @userAccount = get_user_via_api(serverUrl, apiKey, userName) end
Public Instance Methods
active?()
click to toggle source
# File lib/octopus_serverspec_extensions/type/octopus_deploy_user.rb, line 43 def active? return false if @userAccount.nil? @userAccount['IsActive'] == true end
exists?()
click to toggle source
# File lib/octopus_serverspec_extensions/type/octopus_deploy_user.rb, line 39 def exists? (!@userAccount.nil?) && (@userAccount != []) end
has_api_key?(purpose)
click to toggle source
# File lib/octopus_serverspec_extensions/type/octopus_deploy_user.rb, line 58 def has_api_key?(purpose) return false if @userAccount.nil? user_api_key = nil user_id = @userAccount['Id'] url = "#{@serverUrl}/api/users/#{user_id}/apikeys?api-key=#{@apiKey}&take=9999" begin resp = Net::HTTP.get_response(URI.parse(url)) body = JSON.parse(resp.body) keys = body unless body.nil? user_api_key = keys['Items'].select {|i| i['Purpose'] == purpose }.first unless keys.nil? rescue => e raise "has_api_key: Unable to connect to #{url}: #{e}" end !user_api_key.nil? end
has_display_name?(name)
click to toggle source
# File lib/octopus_serverspec_extensions/type/octopus_deploy_user.rb, line 53 def has_display_name?(name) return false if @userAccount.nil? @userAccount['DisplayName'] == name end
has_email?(email)
click to toggle source
# File lib/octopus_serverspec_extensions/type/octopus_deploy_user.rb, line 48 def has_email?(email) return false if @userAccount.nil? @userAccount['EmailAddress'] == email end
service_account?()
click to toggle source
# File lib/octopus_serverspec_extensions/type/octopus_deploy_user.rb, line 34 def service_account? return false if @userAccount.nil? @userAccount['IsService'] == true end