luminati 0.0.2 → 0.0.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: 9adc62b4fd44c0b0e920daf365d0ccc4af9388b8
4
- data.tar.gz: cf70c9548e92575255cd5df94710e7cd8998fee7
3
+ metadata.gz: 100e95b81f766c176f4fb8f97a4a78209728dbfa
4
+ data.tar.gz: c25c2f7b7da62d1d42eef95b72de8898a1494979
5
5
  SHA512:
6
- metadata.gz: efebc81f6a72f0ca7cb1cd43121c9aaa21c9148b4554e61bc1ec96856ed742d7a6fca96c0491acc44f63dc6e301c6406493a0a6295b77f3c1b88f05aa197c463
7
- data.tar.gz: 757cc46a7f860a163ec39e53cd93167cac9e077c37818d91fd76cbb2777f39e0e72be55f84aba56dc92c0436334921d33b3a688af238d24fd21af1088b58958d
6
+ metadata.gz: d5a57daf74528372c6ce2775dbce85db255f1b1efc170ff3d36e53b22686d46c675e6c9552eaca1eb6b8b5938830cd7a72a35bb6abf7aa41aa75b6e19daa1233
7
+ data.tar.gz: 458abb9ce704f54f54a4add49152cff7da717937143698a933b68e2a5f7570cff58cf9ede60f47edebfe8fcd734c0e6354ec72023e41f66f96abd0551a6326a2
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- Luminati (0.0.1)
4
+ luminati (0.0.3)
5
5
  faraday (>= 0.9)
6
+ faraday_middleware (>= 0.9)
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
@@ -10,6 +11,8 @@ GEM
10
11
  diff-lcs (1.2.5)
11
12
  faraday (0.9.1)
12
13
  multipart-post (>= 1.2, < 3)
14
+ faraday_middleware (0.9.1)
15
+ faraday (>= 0.7.4, < 0.10)
13
16
  metaclass (0.0.4)
14
17
  mocha (1.1.0)
15
18
  metaclass (~> 0.0.1)
@@ -19,21 +22,21 @@ GEM
19
22
  rspec-core (~> 3.2.0)
20
23
  rspec-expectations (~> 3.2.0)
21
24
  rspec-mocks (~> 3.2.0)
22
- rspec-core (3.2.0)
25
+ rspec-core (3.2.2)
23
26
  rspec-support (~> 3.2.0)
24
27
  rspec-expectations (3.2.0)
25
28
  diff-lcs (>= 1.2.0, < 2.0)
26
29
  rspec-support (~> 3.2.0)
27
- rspec-mocks (3.2.0)
30
+ rspec-mocks (3.2.1)
28
31
  diff-lcs (>= 1.2.0, < 2.0)
29
32
  rspec-support (~> 3.2.0)
30
- rspec-support (3.2.1)
33
+ rspec-support (3.2.2)
31
34
 
32
35
  PLATFORMS
33
36
  ruby
34
37
 
35
38
  DEPENDENCIES
36
- Luminati!
39
+ luminati!
37
40
  mocha
38
41
  rake
39
42
  rspec
data/README.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Luminati
2
2
  Ruby-wrapper for communicating with the Luminati.io-network.
3
3
 
4
+ ## How to use the wrapper
5
+ Add it to your Gemfile:
6
+ ```ruby
7
+ gem 'luminati'
8
+ ```
9
+
10
+ Basic example:
11
+ ```ruby
12
+ luminati = Luminati::Client.new('username', 'password', zone: 'gen', port: 22225)
13
+ connection = luminati.get_connection(country: nil, dns_resolution: nil, session: nil)
14
+
15
+ session_id = connection[:session_id]
16
+ proxy_user = connection[:username]
17
+ proxy_password = connection[:password]
18
+ proxy_ip = connection[:ip_address]
19
+ proxy_port = connection[:port]
20
+ ```
21
+
22
+ Use a custom zone, only use american ips and resolve dns remotely (on the client nodes):
23
+ ```ruby
24
+ luminati = Luminati::Client.new('username', 'password', zone: 'customzone', port: 22225)
25
+ connection = luminati.get_connection(country: 'us', dns_resolution: :remote, session: nil)
26
+ ```
27
+
28
+ Specify a session to re-use a previously used ip-address:
29
+ ```ruby
30
+ luminati = Luminati::Client.new('username', 'password', zone: 'gen', port: 22225)
31
+ connection = luminati.get_connection(country: 'us', dns_resolution: :remote, session: '4b21543118c63c5a98397c240bee05ae18d0509d')
32
+ ```
33
+
4
34
  ## Test coverage
5
- Currently missing, will be added later.
35
+ Initial test coverage has since 2015-03-20 been added.
36
+
37
+ More tests will be added continously.
@@ -1,5 +1,5 @@
1
1
  module Luminati
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
 
4
4
  require File.join(File.dirname(__FILE__), 'luminati/errors')
5
5
  require File.join(File.dirname(__FILE__), 'luminati/client')
@@ -1,4 +1,5 @@
1
1
  require 'faraday'
2
+ require 'faraday_middleware'
2
3
 
3
4
  module Luminati
4
5
  class Client
@@ -16,7 +17,8 @@ module Luminati
16
17
  }
17
18
 
18
19
  self.regexes = {
19
- failed_auth: /failed\sauth/i
20
+ failed_auth: /failed\sauth/i,
21
+ invalid_params: /invalid\sparams/i
20
22
  }
21
23
  end
22
24
 
@@ -86,8 +88,9 @@ module Luminati
86
88
  end
87
89
 
88
90
  def check_response_for_errors(response)
89
- if (response && response.is_a?(String) && response.present?)
91
+ if (response && response.is_a?(String) && !response.empty?)
90
92
  raise Luminati::FailedAuthError, "Failed to authenticate your account with Luminati.io. Please check your credentials or the contract for your account." if response =~ self.regexes[:failed_auth]
93
+ raise Luminati::InvalidParamsError, "Failed to perform your requested action since invalid parameters were supplied." if response =~ self.regexes[:invalid_params]
91
94
  end
92
95
  end
93
96
 
@@ -1,3 +1,4 @@
1
1
  module Luminati
2
2
  class FailedAuthError < StandardError; end
3
+ class InvalidParamsError < StandardError; end
3
4
  end
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = 'luminati'
6
- s.version = '0.0.2'
6
+ s.version = '0.0.3'
7
7
 
8
8
  s.homepage = "https://github.com/Agiley/Luminati"
9
9
  s.email = "sebastian@agiley.se"
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.summary = "Ruby-wrapper for communicating with the Luminati.io-network."
13
13
 
14
14
  s.add_dependency "faraday", ">= 0.9"
15
+ s.add_dependency "faraday_middleware", ">= 0.9"
15
16
 
16
17
  s.add_development_dependency 'rake'
17
18
  s.add_development_dependency 'rspec'
@@ -28,6 +29,7 @@ Gem::Specification.new do |s|
28
29
  lib/luminati/client.rb
29
30
  lib/luminati/errors.rb
30
31
  luminati.gemspec
32
+ spec/luminati/client_spec.rb
31
33
  spec/spec_helper.rb
32
34
  ]
33
35
  # = MANIFEST =
@@ -0,0 +1,62 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe "Luminati::Client" do
4
+
5
+ context "initialization" do
6
+ it "should set the correct instance variables for a new client with default initialization settings" do
7
+ username = 'user'
8
+ password = 'password'
9
+ client = Luminati::Client.new(username, password)
10
+
11
+ expect(client.username).to be == username
12
+ expect(client.password).to be == password
13
+ expect(client.zone).to be == :gen
14
+ expect(client.port).to be == 22225
15
+ end
16
+
17
+ it "should set the correct instance variables for a new client with custom initialization settings" do
18
+ username = 'user'
19
+ password = 'password'
20
+ client = Luminati::Client.new(username, password, zone: :custom, port: 12345)
21
+
22
+ expect(client.username).to be == username
23
+ expect(client.password).to be == password
24
+ expect(client.zone).to be == :custom
25
+ expect(client.port).to be == 12345
26
+ end
27
+ end
28
+
29
+ context "master proxy" do
30
+ it "should be able to fetch a master proxy with correct credentials" do
31
+ client = Luminati::Client.new(CREDENTIALS['username'], CREDENTIALS['password'])
32
+ proxy = client.fetch_master_proxy
33
+
34
+ expect(proxy).not_to be_nil
35
+ expect(proxy).not_to be_empty
36
+ expect(proxy).to match(Resolv::IPv4::Regex)
37
+ end
38
+
39
+ it "should not be able to fetch a master proxy with incorrect credentials" do
40
+ client = Luminati::Client.new('user', 'password')
41
+ expect{client.fetch_master_proxy}.to raise_error(Luminati::InvalidParamsError)
42
+ end
43
+ end
44
+
45
+ context "connection" do
46
+ it "should successfully be able to retrieve a valid connection with correct credentials" do
47
+ client = Luminati::Client.new(CREDENTIALS['username'], CREDENTIALS['password'])
48
+ connection = client.get_connection
49
+
50
+ expect(connection).not_to be_nil
51
+ expect(connection).not_to be_empty
52
+ expect(connection[:ip_address]).to match(Resolv::IPv4::Regex)
53
+ expect(connection[:port]).to be == 22225
54
+ end
55
+
56
+ it "should not be able to retrieve a valid connection with incorrect credentials" do
57
+ client = Luminati::Client.new('user', 'password')
58
+ expect{client.get_connection}.to raise_error(Luminati::InvalidParamsError)
59
+ end
60
+ end
61
+
62
+ end
@@ -23,4 +23,6 @@ require File.expand_path('../../lib/luminati', __FILE__)
23
23
 
24
24
  RSpec.configure do |config|
25
25
  config.mock_with :mocha
26
- end
26
+ end
27
+
28
+ CREDENTIALS = YAML.load_file(File.join(File.dirname(__FILE__), "/support/credentials.yml"))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luminati
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Johnsson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-16 00:00:00.000000000 Z
11
+ date: 2015-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0.9'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -81,6 +95,7 @@ files:
81
95
  - lib/luminati/client.rb
82
96
  - lib/luminati/errors.rb
83
97
  - luminati.gemspec
98
+ - spec/luminati/client_spec.rb
84
99
  - spec/spec_helper.rb
85
100
  homepage: https://github.com/Agiley/Luminati
86
101
  licenses: []
@@ -106,4 +121,5 @@ signing_key:
106
121
  specification_version: 2
107
122
  summary: Ruby-wrapper for communicating with the Luminati.io-network.
108
123
  test_files:
124
+ - spec/luminati/client_spec.rb
109
125
  - spec/spec_helper.rb