Skip to content

Commit

Permalink
Added HTTPS/SSL support.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgoecke committed May 12, 2011
1 parent a491098 commit d282fc6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.0.17
0.0.18
4 changes: 2 additions & 2 deletions examples/config.yml
@@ -1,5 +1,5 @@
tropo:
username: mcervantes
password: test123
username: jsgoecke
password: sancar119

filename: app_details.yml
2 changes: 1 addition & 1 deletion examples/list_applications.rb
Expand Up @@ -5,7 +5,7 @@
app_details = YAML.load(File.open("examples/#{config['filename']}"))

# Create a new provisioning object with your Tropo credentials
provisioning = TropoProvisioning.new(config['tropo']['username'], config['tropo']['password'], :base_uri => 'http://api-smsified-eng.voxeo.net/v1')
provisioning = TropoProvisioning.new(config['tropo']['username'], config['tropo']['password'], :base_uri => 'http://api.smsified.net/v1')

p provisioning.applications

Expand Down
2 changes: 1 addition & 1 deletion lib/tropo-provisioning.rb
@@ -1,2 +1,2 @@
$: << File.expand_path(File.dirname(__FILE__))
%w(net/http uri active_support active_support/json active_support/inflector hashie tropo-provisioning/tropo-provisioning tropo-provisioning/error.rb).each { |lib| require lib }
%w(net/http net/https uri active_support active_support/json active_support/inflector hashie tropo-provisioning/tropo-provisioning tropo-provisioning/error.rb).each { |lib| require lib }
3 changes: 2 additions & 1 deletion lib/tropo-provisioning/tropo-provisioning.rb
Expand Up @@ -734,7 +734,8 @@ def request(method, params={})
uri = URI.parse(@base_uri)
end
http = Net::HTTP.new(uri.host, uri.port)

http.use_ssl = true if uri.scheme == 'https'

request = set_request_type(method, uri)
request.initialize_http_header(@headers)
request.basic_auth @username, @password
Expand Down
21 changes: 21 additions & 0 deletions spec/tropo-provisioning_spec.rb
Expand Up @@ -341,6 +341,13 @@
:body => ActiveSupport::JSON.encode(@existing_user),
:content_type => "application/json",
:status => ["200", "OK"])

# Get a specific user by username with HTTPS/SSL
FakeWeb.register_uri(:get,
"https://foo:bar@api.tropo.com/v1/users/foo",
:body => ActiveSupport::JSON.encode(@existing_user),
:content_type => "application/json",
:status => ["200", "OK"])

# Invalid credentials
FakeWeb.register_uri(:get,
Expand Down Expand Up @@ -576,6 +583,13 @@
:content_type => "application/json",
:status => ["200", "OK"])

# List invitation for a user via SSL
FakeWeb.register_uri(:get,
"https://foo:bar@api.tropo.com/v1/invitations",
:body => ActiveSupport::JSON.encode(@invitations),
:content_type => "application/json",
:status => ["200", "OK"])

# List invitation for a user
FakeWeb.register_uri(:get,
"http://foo:bar@api.tropo.com/v1/users/15909/invitations/ABC457",
Expand Down Expand Up @@ -1132,4 +1146,11 @@
@tropo_provisioning.invitation('ABC457', '15909').should == @invitations[1]
end
end

describe "HTTPS/SSL support" do
it 'should fetch invitations via HTTPS/SSL' do
tp = TropoProvisioning.new('foo', 'bar', :base_uri => 'https://foo:bar@api.tropo.com/v1')
tp.invitations.should == @invitations
end
end
end
2 changes: 1 addition & 1 deletion tropo-provisioning.gemspec
Expand Up @@ -5,7 +5,7 @@

Gem::Specification.new do |s|
s.name = %q{tropo-provisioning}
s.version = "0.0.17"
s.version = "0.0.18"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Jason Goecke"]
Expand Down

0 comments on commit d282fc6

Please sign in to comment.