amazon_auth 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1dbb0da03518895958625aac116361d7066be7cc
4
- data.tar.gz: b84f4bc692e5d72c30490b1a16f01ae5c63b0f60
2
+ SHA256:
3
+ metadata.gz: 7da5d38fe75349e2e609f1acdef47b251a0a3353ba9693ac7a3961848bdaa645
4
+ data.tar.gz: 28faf4af2fbd6084d62a9bfe9dd8c7b94b200d5cca9b7a8fb14d4d569975284e
5
5
  SHA512:
6
- metadata.gz: 8195b7eed62aaee754064d81f730c9fd693da277de2b61aea7a3e0790003f471929f7f33f366b01e115cff56b422983baf8616b23869d65db599efe36fe7b3b8
7
- data.tar.gz: 74ea3466c4edbad675f93d1ae6bfa909550fcc2105982f9a7af9ca03d2ec6474eb463deade4448d31c87058e6760d9fda012e329839b7de7baa72d40e58825b5
6
+ metadata.gz: 9cee30a8fb0c0955acc36341d980ca9d5545e162199164f2e9f46140e415fcd3e36f92c5910b32c2ec2d1ef64a9e2d20d85b0d63032d28b2a484cb93c7a3fd2d
7
+ data.tar.gz: 8b3655e0a60e5c36686714ba8e98aa1eb5939a1a6358de45b2237a26be58628855c79e4c2802061ca54c4b3b0fa77fa648ecda7d08c27153cea81f8eb6e4c523
@@ -1,7 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.2.7
5
- - 2.3.4
6
- - 2.4.1
7
- before_install: gem install bundler -v 1.14.6
4
+ - 2.5.8
5
+ - 2.6.6
6
+ - 2.7.1
7
+ before_install: gem install bundler
data/Rakefile CHANGED
@@ -3,4 +3,4 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'amazon_auth/version'
@@ -3,12 +3,10 @@
3
3
  require_relative "../lib/amazon_auth"
4
4
  require 'highline/import'
5
5
 
6
- result = []
7
-
8
- domain = ask("Enter your amazon domain: ") { |q| q.echo = true ; q.default = AmazonInfo.domain }
6
+ domain = ask("Enter your amazon domain: ") { |q| q.echo = true; q.default = AmazonInfo.domain }
9
7
  login = ask("Enter your #{domain} username: ") { |q| q.echo = true }
10
8
  passwd = ask("Enter your #{domain} password: ") { |q| q.echo = "*" }
11
- salt = ask("Enter your salt: ") { |q| q.default = AmazonAuth::Converter.default_salt ; q.echo = true }
9
+ salt = ask("Enter your salt: ") { |q| q.default = AmazonAuth::Converter.default_salt; q.echo = true }
12
10
 
13
11
  raise "Empty login or password" if login.to_s.size == 0 || passwd.to_s.size == 0
14
12
 
@@ -1,6 +1,5 @@
1
1
  module AmazonAuth
2
2
  module CommonExtension
3
-
4
3
  def log(message)
5
4
  return unless (@options[:debug] || @options[:verbose])
6
5
  puts "[#{Time.current.strftime('%Y-%m-%d %H:%M:%S')}] #{message}" +
@@ -1,6 +1,5 @@
1
1
  module AmazonAuth
2
2
  module SessionExtension
3
-
4
3
  def doc
5
4
  Nokogiri.HTML(session.html)
6
5
  end
@@ -12,7 +11,7 @@ module AmazonAuth
12
11
 
13
12
  def wait_for_selector(selector, options = {})
14
13
  options.fetch(:wait_time, 3).times do
15
- if session.first(selector)
14
+ if session.first(selector, minimum: 0)
16
15
  break
17
16
  else
18
17
  sleep(1)
@@ -30,7 +29,7 @@ module AmazonAuth
30
29
  session.visit url
31
30
  debug "Visiting #{url}"
32
31
  restore_cookies if keep_cookie?
33
- if (link = links_for('a').find{|link| link =~ %r{\A/gp/navigation/redirector.html} })
32
+ if (link = find_sign_in_link)
34
33
  debug "link: [#{link}]"
35
34
  session.visit(link)
36
35
  end
@@ -50,13 +49,22 @@ module AmazonAuth
50
49
  end
51
50
 
52
51
  def submit_signin_form
53
- session.first('.cvf-account-switcher-profile-details').click if session.has_selector?('.cvf-account-switcher-profile-details')
52
+ # Click account switcher if it is displayed
53
+ dom_account_switcher = '.cvf-account-switcher-profile-details, .cvf-account-switcher-claim'
54
+ session.first(dom_account_switcher).click if session.has_selector?(dom_account_switcher)
55
+
54
56
  debug "Begin submit_signin_form"
55
57
  unless session.has_selector?('#signInSubmit')
56
- log "signInSubmit button not found in this page"
57
- return false
58
+ if session.has_selector?('input#continue') && session.has_selector?('input#ap_email')
59
+ log "Found a form which asks only email"
60
+ session.fill_in 'ap_email', with: login
61
+ session.first('input#continue').click
62
+ else
63
+ log "signInSubmit button not found in this page"
64
+ return false
65
+ end
58
66
  end
59
- session.fill_in 'ap_email', with: login if session.first('#ap_email') && session.first('#ap_email').value.blank?
67
+ session.fill_in 'ap_email', with: login if session.first('#ap_email', minimum: 0) && session.first('#ap_email').value.blank?
60
68
  session.fill_in 'ap_password', with: password
61
69
  session.first('#signInSubmit').click
62
70
  log "Clicked signInSubmit"
@@ -97,13 +105,22 @@ module AmazonAuth
97
105
  session.has_selector?('#auth-captcha-image-container')
98
106
  end
99
107
 
108
+ def find_sign_in_link
109
+ link = links_for('a').find{|l| l =~ %r{\A/gp/navigation/redirector.html} }
110
+ return link if link
111
+ m = session.html.match(%r{'(/gp/navigation/redirector.html[^']+)'})
112
+ return m[1] if m
113
+ nil
114
+ end
115
+
100
116
  private
101
117
 
102
- def login
103
- options.fetch(:login, Converter.decode(ENV['AMAZON_USERNAME_CODE']))
104
- end
105
- def password
106
- options.fetch(:password, Converter.decode(ENV['AMAZON_PASSWORD_CODE']))
107
- end
118
+ def login
119
+ options.fetch(:login, Converter.decode(ENV['AMAZON_USERNAME_CODE']))
120
+ end
121
+
122
+ def password
123
+ options.fetch(:password, Converter.decode(ENV['AMAZON_PASSWORD_CODE']))
124
+ end
108
125
  end
109
126
  end
@@ -1,3 +1,3 @@
1
1
  module AmazonAuth
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazon_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuho Yamaguchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-09 00:00:00.000000000 Z
11
+ date: 2020-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -196,8 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
198
  requirements: []
199
- rubyforge_project:
200
- rubygems_version: 2.6.13
199
+ rubygems_version: 3.0.8
201
200
  signing_key:
202
201
  specification_version: 4
203
202
  summary: Login amazon.