class Serverspec::Type::JenkinsCredential

Public Class Methods

new(name = nil, options = {}) click to toggle source
Calls superclass method Serverspec::Type::JenkinsBase::new
# File lib/serverspec_extra_types/types/jenkins_credential.rb, line 11
def initialize(name = nil, options = {})
  super(name, options)
end

Public Instance Methods

aws_credential?() click to toggle source
# File lib/serverspec_extra_types/types/jenkins_credential.rb, line 41
def aws_credential?
  inspection['typeName'] == 'AWS Credentials'
end
gitlab_api_token?() click to toggle source
# File lib/serverspec_extra_types/types/jenkins_credential.rb, line 37
def gitlab_api_token?
  inspection['typeName'] == 'GitLab API token'
end
has_description?(desc) click to toggle source
# File lib/serverspec_extra_types/types/jenkins_credential.rb, line 53
def has_description?(desc)
  inspection['description'] == desc
end
has_display_name?(text) click to toggle source
# File lib/serverspec_extra_types/types/jenkins_credential.rb, line 57
def has_display_name?(text)
  inspection['displayName'] == text
end
inspection() click to toggle source
# File lib/serverspec_extra_types/types/jenkins_credential.rb, line 15
def inspection
  @inspection ||= ::MultiJson.load(get_inspection.stdout)
end
length() click to toggle source
# File lib/serverspec_extra_types/types/jenkins_credential.rb, line 23
def length
  if inspection.is_a? String
    inspection.length
  elsif inspection.is_a? Array
    inspection.length
  else
    1
  end
end
secret_text?() click to toggle source
# File lib/serverspec_extra_types/types/jenkins_credential.rb, line 49
def secret_text?
  inspection['typeName'] == 'Secret text'
end
ssh_private_key?() click to toggle source
# File lib/serverspec_extra_types/types/jenkins_credential.rb, line 33
def ssh_private_key?
  inspection['typeName'] == 'SSH Username with private key'
end
url() click to toggle source
# File lib/serverspec_extra_types/types/jenkins_credential.rb, line 19
def url
  "#{@url_base}/credentials/store/system/domain/_/credential/#{@name}/api/json"
end
username_with_password?() click to toggle source
# File lib/serverspec_extra_types/types/jenkins_credential.rb, line 45
def username_with_password?
  inspection['typeName'] == 'Username with password'
end

Private Instance Methods

get_inspection() click to toggle source

rubocop:disable Naming/AccessorMethodName

# File lib/serverspec_extra_types/types/jenkins_credential.rb, line 64
def get_inspection
  userpass = @user ? "-u #{@user}:#{@password}" : ''
  command = "curl -s  #{userpass} #{url} #{@insecure ? '-k' : ''} #{@redirects ? '-L' : ''}"
  @get_inspection ||= @runner.run_command(command)
end