vmfloaty 0.2.13 → 0.2.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b950ce194ddc32be50b14e73b343a9b9358fa6d
4
- data.tar.gz: 2dc5f421d0155603a5aa790160d6fa99fc1da869
3
+ metadata.gz: b24b1f8db9ba5d7741f7364868c17976f779cf28
4
+ data.tar.gz: 3ac32fe7709e6e8a2ba39b32aaa503ce92e0e5ab
5
5
  SHA512:
6
- metadata.gz: 3043488a66a670178f94b8c47ff0271b9b0709d0b01cd4df58d0d960f218f0f0edeb25f62e8159f4f7874da10fc4734c2825f26c4effd41a6a9c8511d15aea8d
7
- data.tar.gz: 87cfe6c1f9c171f5482b385e4d92908c4d2b017d05f56de9f1c71adc6d91051b6b3a060cf4de15d8be94a99bac7c5f04bdd9e3f40cb3859e3ac94a6a97447e27
6
+ metadata.gz: 67f4beb31fc6fb3b2880177a301648cd431b4d79097d4a2aa4b74211b7446cf146338dafffb425d5feb7b5d34048dd1d557e36f677e82ecdd26576a466c1d2fe
7
+ data.tar.gz: 63e69b768a855e37d845f7aca4f6221734e1cedeffa63f89453d4ee68da52f65e00dfd5fd553e50b8264dc81240630dbebd5f1e54494800421c910e469e01f52
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  vmfloaty
2
2
  ========
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/vmfloaty.svg)](https://badge.fury.io/rb/vmfloaty)
5
+
4
6
  A CLI helper tool for [Puppet Labs vmpooler](https://github.com/puppetlabs/vmpooler) to help you stay afloat.
5
7
 
6
8
  <img src="http://i.imgur.com/xGcGwuH.jpg" width=200 height=200>
data/lib/vmfloaty/auth.rb CHANGED
@@ -37,13 +37,13 @@ class Auth
37
37
  end
38
38
  end
39
39
 
40
- def self.token_status(verbose, url, user, password, token)
40
+ def self.token_status(verbose, url, token)
41
41
  if token.nil?
42
42
  STDERR.puts 'You did not provide a token'
43
43
  exit 1
44
44
  end
45
45
 
46
- conn = Http.get_conn_with_auth(verbose, url, user, password)
46
+ conn = Http.get_conn(verbose, url)
47
47
 
48
48
  response = conn.get "/token/#{token}"
49
49
  res_body = JSON.parse(response.body)
@@ -14,6 +14,6 @@ class Format
14
14
  end
15
15
  end
16
16
 
17
- puts host_hash.to_json
17
+ host_hash.to_json
18
18
  end
19
19
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  class Version
3
- @version = '0.2.13'
3
+ @version = '0.2.14'
4
4
 
5
5
  def self.get
6
6
  @version
data/lib/vmfloaty.rb CHANGED
@@ -64,7 +64,7 @@ class Vmfloaty
64
64
 
65
65
  unless os_types.nil?
66
66
  response = Pooler.retrieve(verbose, os_types, token, url)
67
- Format.get_hosts(response)
67
+ puts Format.get_hosts(response)
68
68
  else
69
69
  puts 'You did not provide an OS to get'
70
70
  end
@@ -239,15 +239,16 @@ class Vmfloaty
239
239
  url = options.url ||= config['url']
240
240
  token = options.token ||= config['token']
241
241
  user = options.user ||= config['user']
242
- pass = password "Enter your password please:", '*'
243
242
 
244
243
  case action
245
244
  when "get"
245
+ pass = password "Enter your password please:", '*'
246
246
  puts Auth.get_token(verbose, url, user, pass)
247
247
  when "delete"
248
+ pass = password "Enter your password please:", '*'
248
249
  Auth.delete_token(verbose, url, user, pass, token)
249
250
  when "status"
250
- Auth.token_status(verbose, url, user, pass, token)
251
+ Auth.token_status(verbose, url, token)
251
252
  when nil
252
253
  STDERR.puts "No action provided"
253
254
  else
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+ require_relative '../../lib/vmfloaty/auth'
3
+
4
+ describe Pooler do
5
+ before :each do
6
+ @vmpooler_url = "https://vmpooler.example.com"
7
+ end
8
+
9
+ describe "#get_token" do
10
+ before :each do
11
+ @get_token_response = "{\"ok\": true,\"token\":\"utpg2i2xswor6h8ttjhu3d47z53yy47y\"}"
12
+ @token = "utpg2i2xswor6h8ttjhu3d47z53yy47y"
13
+ end
14
+
15
+ it "returns a token from vmpooler" do
16
+ stub_request(:post, "https://first.last:password@vmpooler.example.com/token").
17
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.1'}).
18
+ to_return(:status => 200, :body => @get_token_response, :headers => {})
19
+
20
+ token = Auth.get_token(false, @vmpooler_url, "first.last", "password")
21
+ expect(token).to eq @token
22
+ end
23
+ end
24
+
25
+ describe "#delete_token" do
26
+ before :each do
27
+ @delete_token_response = "{\"ok\":true}"
28
+ @token = "utpg2i2xswor6h8ttjhu3d47z53yy47y"
29
+ end
30
+
31
+ it "deletes the specified token" do
32
+ stub_request(:delete, "https://first.last:password@vmpooler.example.com/token/utpg2i2xswor6h8ttjhu3d47z53yy47y").
33
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1'}).
34
+ to_return(:status => 200, :body => @delete_token_response, :headers => {})
35
+
36
+ #expect(Auth.delete_token(false, @vmpooler_url, "first.last", "password", @token)).to eq @delete_token_response
37
+ end
38
+ end
39
+
40
+ describe "#token_status" do
41
+ before :each do
42
+ @token_status_response = "{\"ok\":true,\"utpg2i2xswor6h8ttjhu3d47z53yy47y\":{\"created\":\"2015-04-28 19:17:47 -0700\"}}"
43
+ @token = "utpg2i2xswor6h8ttjhu3d47z53yy47y"
44
+ end
45
+
46
+ it "checks the status of a token" do
47
+ stub_request(:get, "#{@vmpooler_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y").
48
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1'}).
49
+ to_return(:status => 200, :body => @token_status_response, :headers => {})
50
+
51
+ expect(Auth.token_status(false, @vmpooler_url, @token)).to eq @get_token_response
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+ require_relative '../../lib/vmfloaty/format'
4
+
5
+ describe Pooler do
6
+
7
+ describe "#get_hosts" do
8
+ before :each do
9
+ @hostname_hash = "{\"ok\":true,\"debian-7-i386\":{\"hostname\":[\"sc0o4xqtodlul5w\",\"4m4dkhqiufnjmxy\"]},\"debian-7-x86_64\":{\"hostname\":\"zb91y9qbrbf6d3q\"},\"domain\":\"company.com\"}"
10
+ @format_hash = "{\"debian-7-i386\":[\"sc0o4xqtodlul5w\",\"4m4dkhqiufnjmxy\"],\"debian-7-x86_64\":\"zb91y9qbrbf6d3q\",\"domain\":\"company.com\"}"
11
+ end
12
+
13
+ it "formats a hostname hash into os, hostnames, and domain name" do
14
+
15
+ expect(Format.get_hosts(JSON.parse(@hostname_hash))).to eq @format_hash
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmfloaty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.2.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-16 00:00:00.000000000 Z
11
+ date: 2015-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -57,6 +57,8 @@ files:
57
57
  - lib/vmfloaty/pooler.rb
58
58
  - lib/vmfloaty/version.rb
59
59
  - spec/spec_helper.rb
60
+ - spec/vmfloaty/auth_spec.rb
61
+ - spec/vmfloaty/format_spec.rb
60
62
  - spec/vmfloaty/pooler_spec.rb
61
63
  homepage: https://github.com/briancain/vmfloaty
62
64
  licenses:
@@ -84,4 +86,6 @@ specification_version: 4
84
86
  summary: CLI application to interface with vmpooler
85
87
  test_files:
86
88
  - spec/spec_helper.rb
89
+ - spec/vmfloaty/auth_spec.rb
90
+ - spec/vmfloaty/format_spec.rb
87
91
  - spec/vmfloaty/pooler_spec.rb