boq_com_au 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fd3118b04e20a40ae39b273f80fb634a53fb127bb1cd440eb2d06565fc48a038
4
+ data.tar.gz: b3630039ae37624b2332874b2921175efd3c6655b08d566b0d1fbb6caa2e989e
5
+ SHA512:
6
+ metadata.gz: 0a613acedf24ef2d863fcc8be8fafc5560c3f173f92cbc2204a33dc2301b87e69aaf14b3ee0c43f3bf0c63a1bdec0bb632cedde3eadd2fb76e4f4afdd562915c
7
+ data.tar.gz: cad408ddf596f03df5ab5c4713a27bfccddde667ab9950c4ef736505e72555e17b346eff0827f2fccc0a5676e121a5642d5f6e400cb5afb82978ee38311ad35e
data/CHANGELOG ADDED
@@ -0,0 +1,10 @@
1
+ # boq_com_au/CHANGELOG
2
+
3
+ ## 20261103
4
+
5
+ 0.0.0: Log into and out of BOQ Classic Internet Banking.
6
+
7
+ 1. + BoqComAu::Account < WebAccount: initialize(chrome_profile_directory:), login(), shutdown(), username(), password().
8
+ 2. + BoqComAu::VERSION
9
+ 3. + test/BoqComAu/Account_test.rb
10
+ 4. + boq_com_au.gemspec, Gemfile, Rakefile, README.md, LICENSE.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 thoran
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # boq_com_au
2
+
3
+ ## Description
4
+
5
+ Log into BOQ Classic Internet Banking (ib.boq.com.au), via Selenium WebDriver and WebAccount.
6
+
7
+ myBOQ, BOQ's newer internet banking site, isn't covered.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+ ```ruby
13
+ gem 'boq_com_au'
14
+ ```
15
+ And then execute:
16
+ ```shell
17
+ $ bundle
18
+ ```
19
+ Or install it yourself as:
20
+ ```shell
21
+ $ gem install boq_com_au
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### Logging in, out, and shutting down
27
+ ```ruby
28
+ require 'boq_com_au'
29
+
30
+ boq_account = BoqComAu::Account.new
31
+ boq_account.login
32
+ boq_account.driver # The logged-in browser.
33
+ boq_account.logout
34
+ boq_account.shutdown # Logs out if still logged in, then quits Chrome.
35
+ ```
36
+
37
+ ### Credentials
38
+
39
+ The username is the Customer Access Number. It and the password are given, or set afterwards:
40
+ ```ruby
41
+ boq_account = BoqComAu::Account.new(username: customer_access_number, password: password)
42
+ boq_account.username, boq_account.password = customer_access_number, password
43
+ ```
44
+ Where either is missing, `login` stops, saying which.
45
+
46
+ ### The browser
47
+
48
+ Chrome is started with its automation flags masked. Given a `chrome_profile_directory`, it's started with that profile, kept between runs, so as the bank sees a returning browser rather than a fresh automated one; without one, each run has a new, temporary profile.
49
+ ```ruby
50
+ BoqComAu::Account.new(chrome_profile_directory: '~/path/to/chrome-profile')
51
+ ```
52
+ Passing `browser:` or `driver_options:` to `BoqComAu::Account.new` replaces all of that, as for any WebAccount.
53
+
54
+ Where BOQ asks for a one-time code after logging on, `login` waits up to 30 seconds for it to be entered in the browser.
55
+
56
+ ## Limitations
57
+
58
+ The login page's selectors were taken from the live page. BOQ's ids are generated, so things are found by their labels and text, and a change to the wording of the site will break it.
59
+
60
+ The tests cover only what doesn't depend on BOQ's site.
61
+
62
+ ## Contributing
63
+
64
+ 1. Fork it: https://github.com/thoran/boq_com_au/fork
65
+ 2. Create your feature branch: `git checkout -b my-new-feature`
66
+ 3. Commit your changes: `git commit -am 'Add some feature'`
67
+ 4. Push to the branch: `git push origin my-new-feature`
68
+ 5. Create a new pull request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ # Rakefile
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.test_files = FileList['test/**/*_test.rb']
7
+ end
8
+
9
+ task default: :test
@@ -0,0 +1,49 @@
1
+ require_relative './lib/BoqComAu/VERSION'
2
+
3
+ class Gem::Specification
4
+ def dependencies=(gems)
5
+ gems.each{|gem| add_dependency(*gem)}
6
+ end
7
+
8
+ def development_dependencies=(gems)
9
+ gems.each{|gem| add_development_dependency(*gem)}
10
+ end
11
+ end
12
+
13
+ Gem::Specification.new do |spec|
14
+ spec.name = 'boq_com_au'
15
+ spec.version = BoqComAu::VERSION
16
+
17
+ spec.summary = "Log into BOQ Classic Internet Banking via Selenium WebDriver."
18
+ spec.description = "Log into BOQ Classic Internet Banking with a Customer Access Number and password."
19
+
20
+ spec.author = 'thoran'
21
+ spec.email = 'code@thoran.com'
22
+ spec.homepage = 'https://github.com/thoran/boq_com_au'
23
+ spec.license = 'MIT'
24
+
25
+ spec.require_paths = ['lib']
26
+ spec.required_ruby_version = '>= 3.3'
27
+
28
+ spec.files = [
29
+ 'boq_com_au.gemspec',
30
+ Dir['lib/**/*.rb'],
31
+ Dir['test/**/*.rb'],
32
+ 'CHANGELOG',
33
+ 'Gemfile',
34
+ 'LICENSE',
35
+ 'Rakefile',
36
+ 'README.md',
37
+ ].flatten
38
+
39
+ spec.dependencies = [
40
+ ['selenium-webdriver', '>= 4.0'],
41
+ ['webaccount', '>= 0.6.0']
42
+ ]
43
+
44
+ spec.development_dependencies = %w{
45
+ minitest
46
+ minitest-spec-context
47
+ rake
48
+ }
49
+ end
@@ -0,0 +1,80 @@
1
+ # BoqComAu/Account.rb
2
+ # BoqComAu::Account
3
+
4
+ # Notes:
5
+ # 1. The login page's ids and names (id4, 8, ...) appear to be generated, so the fields are found by their labels.
6
+ # 2. Where a one-time code is asked for after logging on, login() waits default_wait_timeout seconds for it to be entered by hand.
7
+ # 3. Chrome is started with its automation flags masked; and, given a chrome_profile_directory, with that profile, kept between runs, so as the bank sees a returning browser rather than a fresh automated one.
8
+ # 4. A username or password not given stops login, saying which is missing.
9
+
10
+ require 'webaccount'
11
+
12
+ module BoqComAu
13
+ class Account < WebAccount
14
+ PAGE_SELECTORS = {
15
+ login_page_url: 'https://www.ib.boq.com.au/boqbl/BankFast-Enterprise-Logon',
16
+ login_page_username_field_selector: {xpath: '//input[@id=//label[normalize-space()="Customer Access Number"]/@for]'},
17
+ login_page_password_field_selector: {xpath: '//input[@id=//label[normalize-space()="Password"]/@for]'},
18
+ login_page_submit_button_selector: {id: 'btnSignIn'},
19
+ logout_button_selector: {xpath: '//a[contains(translate(normalize-space(), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"), "log off")]'},
20
+ logged_out_xpath: '//input[@id="btnSignIn"]'
21
+ }
22
+
23
+ def username
24
+ @username || raise("No username: it's given as username:.")
25
+ end
26
+
27
+ def password
28
+ @password || raise("No password: it's given as password:.")
29
+ end
30
+
31
+ def login(username: nil, password: nil)
32
+ @logged_in = false
33
+ username ||= self.username
34
+ password ||= self.password
35
+ driver.attempt do
36
+ get_login_page
37
+ enter_username(username)
38
+ enter_password(password)
39
+ login_page_submit_button.click
40
+ end
41
+ @logged_in = driver_wait.until{!driver.element_present?(:id, 'btnSignIn')}
42
+ end
43
+ alias_method :logon, :login
44
+
45
+ # Chrome is quit whether or not logging out succeeds, so as a failed logout doesn't leave a logged-in browser behind.
46
+ def shutdown
47
+ logout if logged_in?
48
+ ensure
49
+ driver.quit
50
+ end
51
+
52
+ private
53
+
54
+ def initialize(username: nil, password: nil, chrome_profile_directory: nil, browser: nil, driver_options: nil)
55
+ @chrome_profile_directory = chrome_profile_directory && File.expand_path(chrome_profile_directory)
56
+ super(
57
+ username: username, password: password,
58
+ browser: browser, driver_options: driver_options,
59
+ login_page_url: PAGE_SELECTORS[:login_page_url],
60
+ login_page_username_field_selector: PAGE_SELECTORS[:login_page_username_field_selector],
61
+ login_page_password_field_selector: PAGE_SELECTORS[:login_page_password_field_selector],
62
+ login_page_submit_button_selector: PAGE_SELECTORS[:login_page_submit_button_selector],
63
+ logout_button_selector: PAGE_SELECTORS[:logout_button_selector],
64
+ logged_out_xpath: PAGE_SELECTORS[:logged_out_xpath],
65
+ )
66
+ end
67
+
68
+ # driver construction
69
+
70
+ def default_driver_options
71
+ return unless browser == :chrome
72
+ Selenium::WebDriver::Chrome::Options.new.tap do |o|
73
+ o.add_argument("--user-data-dir=#{@chrome_profile_directory}") if @chrome_profile_directory
74
+ o.add_argument('--disable-blink-features=AutomationControlled')
75
+ o.exclude_switches << 'enable-automation'
76
+ o.add_preference(:credentials_enable_service, false)
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,6 @@
1
+ # BoqComAu/VERSION.rb
2
+ # BoqComAu::VERSION
3
+
4
+ module BoqComAu
5
+ VERSION = '0.0.0'
6
+ end
data/lib/boq_com_au.rb ADDED
@@ -0,0 +1,5 @@
1
+ # boq_com_au.rb
2
+ # BoqComAu
3
+
4
+ require_relative './BoqComAu/Account'
5
+ require_relative './BoqComAu/VERSION'
@@ -0,0 +1,78 @@
1
+ # test/BoqComAu/Account_test.rb
2
+
3
+ # Notes:
4
+ # 1. No browser and no BOQ: only what doesn't depend on the site is tested. Every account which might reach for its browser is given a stand-in, so as none is started.
5
+
6
+ require_relative '../../lib/boq_com_au'
7
+
8
+ require 'minitest/autorun'
9
+ require 'minitest-spec-context'
10
+
11
+ describe BoqComAu::Account do
12
+ def stand_in_driver
13
+ driver = Object.new
14
+ driver.define_singleton_method(:quit){@quit = true}
15
+ driver.define_singleton_method(:quit?){!!@quit}
16
+ driver
17
+ end
18
+
19
+ def account_with_driver(driver, logged_in: true)
20
+ account = BoqComAu::Account.new
21
+ account.instance_variable_set(:@driver, driver)
22
+ account.instance_variable_set(:@logged_in, logged_in)
23
+ account
24
+ end
25
+
26
+ describe "#username and #password" do
27
+ it "are those given" do
28
+ account = BoqComAu::Account.new(username: 'customer', password: 'secret')
29
+ _(account.username).must_equal('customer')
30
+ _(account.password).must_equal('secret')
31
+ end
32
+
33
+ it "can be set after construction" do
34
+ account = BoqComAu::Account.new
35
+ account.username, account.password = 'customer', 'secret'
36
+ _(account.username).must_equal('customer')
37
+ _(account.password).must_equal('secret')
38
+ end
39
+
40
+ it "say which is missing where they're not given, rather than reading the environment" do
41
+ ENV['BOQ_USERNAME'], ENV['BOQ_PASSWORD'] = 'customer', 'secret'
42
+ account = BoqComAu::Account.new
43
+ _(_{account.username}.must_raise(RuntimeError).message).must_include('No username')
44
+ _(_{account.password}.must_raise(RuntimeError).message).must_include('No password')
45
+ ensure
46
+ ENV.delete('BOQ_USERNAME')
47
+ ENV.delete('BOQ_PASSWORD')
48
+ end
49
+ end
50
+
51
+ describe "#shutdown" do
52
+ it "quits the browser even where logging out fails" do
53
+ driver = stand_in_driver
54
+ account = account_with_driver(driver)
55
+ account.define_singleton_method(:logout){raise Selenium::WebDriver::Error::TimeoutError}
56
+ _{account.shutdown}.must_raise(Selenium::WebDriver::Error::TimeoutError)
57
+ _(driver.quit?).must_equal(true)
58
+ end
59
+ end
60
+
61
+ describe "#default_driver_options" do
62
+ it "masks Chrome's automation flags, leaving the profile to Chrome where none is given" do
63
+ options = BoqComAu::Account.new.send(:default_driver_options)
64
+ _(options.args).must_include('--disable-blink-features=AutomationControlled')
65
+ _(options.exclude_switches).must_include('enable-automation')
66
+ _(options.args.grep(/--user-data-dir/)).must_be_empty
67
+ end
68
+
69
+ it "starts Chrome with the profile given, expanded" do
70
+ options = BoqComAu::Account.new(chrome_profile_directory: '~/profiles/boq').send(:default_driver_options)
71
+ _(options.args).must_include("--user-data-dir=#{File.expand_path('~/profiles/boq')}")
72
+ end
73
+
74
+ it "is nil for browsers other than Chrome" do
75
+ _(BoqComAu::Account.new(browser: :firefox).send(:default_driver_options)).must_be_nil
76
+ end
77
+ end
78
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: boq_com_au
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - thoran
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: selenium-webdriver
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '4.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '4.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: webaccount
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.6.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 0.6.0
40
+ - !ruby/object:Gem::Dependency
41
+ name: minitest
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: minitest-spec-context
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: rake
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ description: Log into BOQ Classic Internet Banking with a Customer Access Number and
83
+ password.
84
+ email: code@thoran.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - CHANGELOG
90
+ - Gemfile
91
+ - LICENSE
92
+ - README.md
93
+ - Rakefile
94
+ - boq_com_au.gemspec
95
+ - lib/BoqComAu/Account.rb
96
+ - lib/BoqComAu/VERSION.rb
97
+ - lib/boq_com_au.rb
98
+ - test/BoqComAu/Account_test.rb
99
+ homepage: https://github.com/thoran/boq_com_au
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '3.3'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubygems_version: 4.0.23
118
+ specification_version: 4
119
+ summary: Log into BOQ Classic Internet Banking via Selenium WebDriver.
120
+ test_files: []