shelly 0.5.2 → 0.5.3

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: 5400f1e980ab492924c5d9d6b67fb9a671d93d7f
4
- data.tar.gz: 435c76b4729f0935dcaec9fa16c7131023ab3dde
3
+ metadata.gz: b8ceb2fd1ee786894862ba5705645a85570e3cd2
4
+ data.tar.gz: 09486cb2b72d9926e1e9788f6aa47adbadc13fea
5
5
  SHA512:
6
- metadata.gz: c2a6937d6fafd7926a27261bb033fcf6f4995c585fd14448514d3268686958deb7533ea89183ededeeb92ed934eb44881351847c2051e66e0ff8877559387a53
7
- data.tar.gz: ae28007a02699354345cbbefa65841a14713508899eec426a46f345342407b812f089adfd5a759f80ad0b3ce33bb982bb34ac9ae0a69efa420f85359e923134d
6
+ metadata.gz: 88c7950e4fa032ecbdadd102520fd5d824e16980dda250aa270e449671840fbefa1f72aa836621151c83a78f1eb4c97d2306dd626ab1b1b1a4b13915c2bd3c1a
7
+ data.tar.gz: b34402a098cb424aea9e1f843a31f411c499656e2caaf8b8cfc52ca913514129a73682e0d175e591b2cbb20c58f0c511df3540b3eee83ad2eadec61527e86b6d
@@ -1,3 +1,9 @@
1
+ ## 0.5.3 / 2015-02-15
2
+
3
+ * [bugfix] Don't ask user about assigning new ip address on creating new
4
+ endpoint with SNI
5
+ * [improvement] User is able to provide referral code for new organization
6
+
1
7
  ## 0.5.2 / 2015-02-11
2
8
 
3
9
  * [improvement] Disable email confirmation on registration
@@ -79,6 +79,7 @@ module Shelly
79
79
  def create(cert_path = nil, key_path = nil, bundle_path = nil)
80
80
  app = multiple_clouds(options[:cloud],
81
81
  "endpoint create [CERT_PATH] [KEY_PATH] [BUNDLE_PATH]")
82
+ sni = options["sni"]
82
83
 
83
84
  say "Every unique IP address assigned to endpoint costs 10€/month"
84
85
  say "It's required for SSL/TLS"
@@ -87,7 +88,7 @@ module Shelly
87
88
  say "Assigned IP address can be used to catch all domains pointing to that address, without SSL/TLS enabled"
88
89
  exit(0) unless yes?("Are you sure you want to create endpoint without certificate (yes/no):")
89
90
  elsif app.endpoints.count > 0
90
- ask_if_endpoints_were_already_created(app)
91
+ ask_if_endpoints_were_already_created(app, sni)
91
92
  else
92
93
  exit(0) unless yes?("Are you sure you want to create endpoint? (yes/no):")
93
94
  end
@@ -95,7 +96,7 @@ module Shelly
95
96
  certificate, key = read_certificate_components(cert_path, key_path,
96
97
  bundle_path)
97
98
 
98
- endpoint = app.create_endpoint(certificate, key, options["sni"])
99
+ endpoint = app.create_endpoint(certificate, key, sni)
99
100
 
100
101
  say "Endpoint was created for #{app} cloud", :green
101
102
  if endpoint['ip_address']
@@ -184,14 +185,19 @@ module Shelly
184
185
  end
185
186
  end
186
187
 
187
- def ask_if_endpoints_were_already_created(app)
188
+ def ask_if_endpoints_were_already_created(app, sni)
188
189
  cli = Shelly::CLI::Endpoint.new
189
190
  cli.options = {:cloud => app}
190
191
  cli.list
191
192
  say_new_line
192
- exit(0) unless yes?("You already have assigned endpoint(s). Are " \
193
- "you sure you want to create another one with a new IP address? " \
194
- "(yes/no):")
193
+ question = unless sni.nil?
194
+ "You already have assigned endpoint(s). Are you sure you" \
195
+ " want to create another one with SNI? (yes/no):"
196
+ else
197
+ "You already have assigned endpoint(s). Are you sure you" \
198
+ " want to create another one with a new IP address? (yes/no):"
199
+ end
200
+ exit(0) unless yes?(question)
195
201
  end
196
202
  end
197
203
  end
@@ -11,6 +11,8 @@ module Shelly
11
11
  :desc => "Server size [large, small]"
12
12
  method_option "redeem-code", :type => :string, :aliases => "-r",
13
13
  :desc => "Redeem code for free credits"
14
+ method_option "referral-code", :type => :string,
15
+ :desc => "Referral code for additional credit"
14
16
  method_option "organization", :type => :string, :aliases => "-o",
15
17
  :desc => "Add cloud to existing organization"
16
18
  method_option "skip-requirements-check", :type => :boolean,
@@ -26,6 +26,8 @@ module Shelly
26
26
 
27
27
  method_option "redeem-code", :type => :string, :aliases => "-r",
28
28
  :desc => "Redeem code for free credits"
29
+ method_option "referral-code", :type => :string,
30
+ :desc => "Referral code for additional credit"
29
31
  desc "add", "Add a new organization"
30
32
  map "create" => :add
31
33
  map "new" => :add
@@ -7,8 +7,9 @@ class Shelly::Client
7
7
  get("/organizations/#{name}")
8
8
  end
9
9
 
10
- def create_organization(attributes)
11
- post("/organizations", :organization => attributes)
10
+ def create_organization(attributes, referral_code = nil)
11
+ post("/organizations", :organization => attributes,
12
+ :referral_code => referral_code)
12
13
  end
13
14
 
14
15
  def members(name)
@@ -24,6 +24,7 @@ module Shelly
24
24
  organization = Shelly::Organization.new
25
25
  organization.name = ask_for_organization_name
26
26
  organization.redeem_code = options["redeem-code"]
27
+ organization.referral_code = options["referral-code"]
27
28
  organization.create
28
29
  say "Organization '#{organization.name}' created", :green
29
30
  organization.name
@@ -1,6 +1,6 @@
1
1
  module Shelly
2
2
  class Organization < Model
3
- attr_accessor :name, :app_code_names, :redeem_code
3
+ attr_accessor :name, :app_code_names, :redeem_code, :referral_code
4
4
 
5
5
  def initialize(attributes = {})
6
6
  @name = attributes["name"]
@@ -15,7 +15,7 @@ module Shelly
15
15
 
16
16
  def create
17
17
  attributes = {:name => name, :redeem_code => redeem_code}
18
- shelly.create_organization(attributes)
18
+ shelly.create_organization(attributes, referral_code)
19
19
  end
20
20
 
21
21
  def memberships
@@ -1,3 +1,3 @@
1
1
  module Shelly
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -76,21 +76,49 @@ describe Shelly::CLI::Endpoint do
76
76
  @app.stub(:endpoints).and_return([])
77
77
  end
78
78
 
79
- it "should create endpoint with provided certificate" do
80
- @app.should_receive(:create_endpoint).with("crt\n", "key", true).
81
- and_return(endpoint_response('ip_address' => '10.0.0.1'))
79
+ context "with certificate" do
80
+ it "should create endpoint with provided certificate" do
81
+ @app.should_receive(:create_endpoint).with("crt\n", "key", nil).
82
+ and_return(endpoint_response('ip_address' => '10.0.0.1'))
82
83
 
83
- $stdout.should_receive(:puts).with("Every unique IP address assigned to endpoint costs 10\u20AC/month")
84
- $stdout.should_receive(:puts).with("It's required for SSL/TLS")
85
- $stdout.should_receive(:print).with("Are you sure you want to create endpoint? (yes/no): ")
84
+ $stdout.should_receive(:puts).with("Every unique IP address assigned to endpoint costs 10\u20AC/month")
85
+ $stdout.should_receive(:puts).with("It's required for SSL/TLS")
86
+ $stdout.should_receive(:print).with("Are you sure you want to create endpoint? (yes/no): ")
86
87
 
87
- $stdout.should_receive(:puts).with(green "Endpoint was created for #{@app.to_s} cloud")
88
- $stdout.should_receive(:puts).with("Deployed certificate on front end servers.")
89
- $stdout.should_receive(:puts).with("Point your domain to private IP address: 10.0.0.1")
88
+ $stdout.should_receive(:puts).with(green "Endpoint was created for #{@app.to_s} cloud")
89
+ $stdout.should_receive(:puts).with("Deployed certificate on front end servers.")
90
+ $stdout.should_receive(:puts).with("Point your domain to private IP address: 10.0.0.1")
90
91
 
91
- @cli.options = {"sni" => true}
92
- fake_stdin(["yes"]) do
93
- invoke(@cli, :create, "crt_path", "key_path")
92
+ fake_stdin(["yes"]) do
93
+ invoke(@cli, :create, "crt_path", "key_path")
94
+ end
95
+ end
96
+
97
+ context "when sni option is true" do
98
+ before do
99
+ @app.stub_chain(:endpoints, :count).and_return(1)
100
+ @cli.stub(:list)
101
+ end
102
+
103
+ it "should create endpoint with provided certificate" do
104
+ @app.should_receive(:create_endpoint).with("crt\n", "key", true).
105
+ and_return(endpoint_response('ip_address' => '10.0.0.1'))
106
+
107
+ $stdout.should_receive(:puts).with("Every unique IP address assigned to endpoint costs 10\u20AC/month")
108
+ $stdout.should_receive(:puts).with("It's required for SSL/TLS")
109
+ $stdout.should_receive(:puts).with("\n")
110
+ $stdout.should_receive(:print).with("You already have assigned" \
111
+ " endpoint(s). Are you sure you want to create another one with" \
112
+ " SNI? (yes/no): ")
113
+ $stdout.should_receive(:puts).with(green "Endpoint was created for #{@app.to_s} cloud")
114
+ $stdout.should_receive(:puts).with("Deployed certificate on front end servers.")
115
+ $stdout.should_receive(:puts).with("Point your domain to private IP address: 10.0.0.1")
116
+
117
+ @cli.options = {"sni" => true}
118
+ fake_stdin(["yes"]) do
119
+ invoke(@cli, :create, "crt_path", "key_path")
120
+ end
121
+ end
94
122
  end
95
123
  end
96
124
 
@@ -668,7 +668,7 @@ More info at http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository\e[0m
668
668
  it "should ask user to create a new organization" do
669
669
  @app.should_receive(:organization_name=).with('org-name')
670
670
  @client.should_receive(:create_organization).
671
- with({:name => "org-name", :redeem_code => nil})
671
+ with({:name => "org-name", :redeem_code => nil}, nil)
672
672
  $stdout.should_receive(:print).
673
673
  with("Organization name (foo - default): ")
674
674
  $stdout.should_receive(:puts).
@@ -681,7 +681,16 @@ More info at http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository\e[0m
681
681
  it "should use --redeem-code option" do
682
682
  @main.options = {'redeem-code' => 'discount'}
683
683
  @client.should_receive(:create_organization).
684
- with({:name => "org-name", :redeem_code => 'discount'})
684
+ with({:name => "org-name", :redeem_code => 'discount'}, nil)
685
+ fake_stdin(["foo", "none", "", "org-name"]) do
686
+ invoke(@main, :add)
687
+ end
688
+ end
689
+
690
+ it "should use --referral-code option" do
691
+ @main.options = {'referral-code' => 'test'}
692
+ @client.should_receive(:create_organization).
693
+ with({:name => "org-name", :redeem_code=>nil}, 'test')
685
694
  fake_stdin(["foo", "none", "", "org-name"]) do
686
695
  invoke(@main, :add)
687
696
  end
@@ -85,6 +85,14 @@ describe Shelly::CLI::Organization do
85
85
  end
86
86
  end
87
87
 
88
+ it "should accept referral-code option" do
89
+ @organization.should_receive(:referral_code=).with("test")
90
+ @cli.options = {"referral-code" => "test"}
91
+ fake_stdin("org-name") do
92
+ invoke(@cli, :add)
93
+ end
94
+ end
95
+
88
96
  context "on failure" do
89
97
  it "should display validation errors" do
90
98
  body = {"message" => "Validation Failed", "errors" =>
@@ -192,7 +192,7 @@ describe Shelly::Client do
192
192
  describe "#create_organization" do
193
193
  it "should send post with organization's attributes" do
194
194
  @client.should_receive(:post).with("/organizations",
195
- :organization => {:name => "new-organization"})
195
+ {:organization=>{:name=>"new-organization"}, :referral_code=>nil})
196
196
  @client.create_organization(:name => "new-organization")
197
197
  end
198
198
  end
@@ -65,9 +65,10 @@ describe Shelly::Organization do
65
65
  describe "#create" do
66
66
  it "should create organization via API client" do
67
67
  @client.should_receive(:create_organization).with(
68
- :name => "new-organization", :redeem_code => "discount")
68
+ {:name=>"new-organization", :redeem_code=>"discount"}, "test")
69
69
  @organization.name = "new-organization"
70
70
  @organization.redeem_code = "discount"
71
+ @organization.referral_code = "test"
71
72
  @organization.create
72
73
  end
73
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shelly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shelly Cloud team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-11 00:00:00.000000000 Z
11
+ date: 2015-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -359,7 +359,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
359
359
  version: '0'
360
360
  requirements: []
361
361
  rubyforge_project: shelly
362
- rubygems_version: 2.2.2
362
+ rubygems_version: 2.4.5
363
363
  signing_key:
364
364
  specification_version: 4
365
365
  summary: Shelly Cloud command line tool