turksatkablo_cli 0.3.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1128eb6df786323a3170be8301fecf50eaccc646
4
+ data.tar.gz: 35e0abf2cc9692490b0513f8f988970ac6570ea5
5
+ SHA512:
6
+ metadata.gz: 6a6874d69e8d6e09816f44bcc1ea0acf33b799636e5ddd3d3c45121aeeca156276d49488315867b4956e67e562e4bd86413f6ef70f780f681100cc1fc559c7d9
7
+ data.tar.gz: 326587e3cd001120690956a659f0f88a4a6f616902ae65fdf11ac2c0874cd306cfd8ef07e29629d2380c52b281532a863ba54e4ec33efafb7679be32a3d22391
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+ rspec_logs.json
12
+ test_output/
13
+ .DS_STORE
14
+ .keys
15
+ *.png
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ Gemfile.lock
31
+ .ruby-version
32
+ .ruby-gemset
33
+
34
+ # Dotenv
35
+ .env
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at rokumatsumoto@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in turksatkablo_cli.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Samet Gunaydin
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ Turksat Kablo CLI :black_medium_square:
2
+ =================
3
+ [![Gem Version](https://badge.fury.io/rb/turksatkablo_cli.svg)](https://badge.fury.io/rb/turksatkablo_cli)
4
+
5
+ A command-line interface for the Turksat Kablo Online Islemler - https://online.turksatkablo.com.tr/
6
+
7
+
8
+ ## Demo
9
+
10
+ [![asciicast](https://asciinema.org/a/O5JIljKHQjTe3cRZNDLBngJXS.png)](https://asciinema.org/a/O5JIljKHQjTe3cRZNDLBngJXS)
11
+
12
+ ## Setup
13
+
14
+ turksatkablo_cli is built with Ruby, so you'll need a working Ruby 2.2.0>= environment to use it. You can find Ruby installation instructions [here](https://www.ruby-lang.org/en/installation/).
15
+
16
+
17
+ 1. Install via rubygems
18
+
19
+ ```bash
20
+ gem install turksatkablo_cli
21
+ ```
22
+
23
+ 2. Install PhantomJS
24
+
25
+ https://github.com/teampoltergeist/poltergeist#installing-phantomjs
26
+
27
+
28
+
29
+ Verify the `turksatkablo` command is in your path by running it. You should see information about available commands.
30
+
31
+ ```
32
+ $ turksatkablo
33
+ Commands:
34
+ turksatkablo anlikborc # Anlık borç - kısa kodu b
35
+ turksatkablo fatura TARIH # Fatura göster ÖRN: 12.2017, ÖRN: 12.2017 pdf - kısa kodu f
36
+ turksatkablo faturaliste # Fatura listesi - kısa kodu fl
37
+ turksatkablo help [COMMAND] # Describe available commands or one specific command
38
+ turksatkablo hizmet # Mevcut hizmetler - kısa kodu h
39
+ turksatkablo kampanya # Kampanya bilgileri - kısa kodu ka
40
+ turksatkablo kota # Kalan kota - kısa kodu k
41
+ turksatkablo kotadetay # Son 3 ay kota kullanım - kısa kodu kd
42
+ turksatkablo musterino # Müşteri no - kısa kodu mn
43
+ turksatkablo ozet # Hizmetler genel durum - kısa kodu o
44
+ ```
45
+
46
+ ## Changelog
47
+ + 0.3.0 – Add `Code coverage`, `Windows 10` support and `fatura TARIH`, `faturaliste`, `kotadetay donem` commands.
48
+ + 0.2.0 – Add `RSpec` and `environment` tests, required `ruby` version updated (2.2.0 >=), `nokogiri` version updated (has a known critical severity security vulnerability in version range < 1.8.1)
49
+ + 0.1.4 – Fix retry_authenticate and authenticated? methods (login details could not be saved after the retry_authenticate method)
50
+ + 0.1.3 – Modernize multiple classes, add `ozet`, `hizmetler`, `musterino`, `kampanya`, `anlikborc` commands
51
+ + 0.1.2 – Modernize Agent and Auth classes, ability to save user's encrypted login details, add `kota` command.
52
+ + 0.1.1 – Build app skeleton, implement basic authentication
53
+ + 0.1.0 - Initial version.
54
+
55
+ ### Development
56
+ ```bash
57
+ bundle exec rspec -fd spec
58
+ ```
59
+
60
+ ### Contributing
61
+
62
+ turksatkablo_cli is open source, and contributions are very welcome!
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ begin
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+ rescue LoadError
8
+ # no rspec available
9
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "turksatkablo_cli"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/turksatkablo ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ ## encoding: utf-8
3
+
4
+ lib_dir = File.expand_path("../../lib", __FILE__)
5
+ $LOAD_PATH.unshift lib_dir if File.directory?(lib_dir)
6
+
7
+ require 'turksatkablo_cli/online_operations/helpers'
8
+ require 'turksatkablo_cli/online_operations/enums'
9
+
10
+ TurksatkabloCli::OnlineOperations::Helpers.check_ruby_version
11
+ TurksatkabloCli::OnlineOperations::Helpers.check_is_installed?("phantomjs", TurksatkabloCli::OnlineOperations::Enums::PHANTOM_JS_REQUIRED)
12
+
13
+ require 'turksatkablo_cli'
14
+
15
+ # catch control-c and exit
16
+ trap("SIGINT") do
17
+ Capybara.current_session.driver.quit
18
+ exit!
19
+ end
20
+
21
+
22
+ at_exit{
23
+ # cleanup temp files
24
+ # close open connections
25
+ Capybara.current_session.driver.quit
26
+ }
27
+
28
+ TurksatkabloCli.main
@@ -0,0 +1,12 @@
1
+ # Require the gems
2
+ require 'capybara/poltergeist'
3
+
4
+ # Configure Poltergeist to not blow up on websites with js errors aka every website with js
5
+ # See more options at https://github.com/teampoltergeist/poltergeist#customization
6
+ options = { js_errors: false, phantomjs_options: ['--load-images=no', '--ignore-ssl-errors=yes'] }
7
+ Capybara.register_driver :poltergeist do |app|
8
+ Capybara::Poltergeist::Driver.new(app, options)
9
+ end
10
+
11
+ # Configure Capybara to use Poltergeist as the driver
12
+ Capybara.default_driver = :poltergeist
@@ -0,0 +1,33 @@
1
+ require 'turksatkablo_cli/online_operations/version'
2
+ require 'turksatkablo_cli/base'
3
+ require 'turksatkablo_cli/online_operations/agent'
4
+ require 'turksatkablo_cli/online_operations/auth'
5
+ require "init/poltergeist"
6
+ require 'turksatkablo_cli/online_operations/commands/quota'
7
+
8
+ module TurksatkabloCli
9
+ class << self
10
+ def main
11
+ if !TurksatkabloCli::OnlineOperations::Helpers.internet_connection?
12
+ abort 'İnternet bağlantınızı kontrol ediniz!'
13
+ # Check your internet connection!
14
+ end
15
+
16
+ require 'turksatkablo_cli/online_operations/cli'
17
+
18
+ TurksatkabloCli::OnlineOperations::Cli.start(ARGV)
19
+
20
+ end
21
+
22
+
23
+ end
24
+
25
+ end
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
@@ -0,0 +1,16 @@
1
+ require 'thor'
2
+
3
+ module TurksatkabloCli
4
+ module OnlineOperations
5
+ class Base < Thor
6
+ include Helpers
7
+ include Thor::Actions
8
+
9
+ # exit with return code 1 in case of a error
10
+ def self.exit_on_failure?
11
+ Capybara.current_session.driver.quit
12
+ true
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,145 @@
1
+ require 'highline'
2
+
3
+ module TurksatkabloCli
4
+ module OnlineOperations
5
+ class Agent
6
+ include Helpers
7
+ attr_accessor :login_choose, :username, :password, :radio_btn_value,
8
+ :fail_login_attempt, :session, :has_logged_in
9
+
10
+ def initialize
11
+ @session = Capybara::Session.new(:poltergeist)
12
+ @login_type = { musterino: {username_label: "Müşteri No", password_label: "Şifre", radio_btn_value: 1},
13
+ tckimlikno: {username_label: "T.C. Kimlik No", password_label: "Şifre", radio_btn_value: 2},
14
+ email: {username_label: "E-mail", password_label: "Şifre", radio_btn_value: 4},
15
+ ceptelefonu: {username_label: "Cep Telefonu (Başında 0 olmadan 10 haneli olmalı.)", password_label: "Şifre", radio_btn_value: 5} }
16
+ @fail_login_attempt = 0
17
+ @has_logged_in = false
18
+ end
19
+
20
+ def has_logged_in?
21
+ self.has_logged_in
22
+ end
23
+
24
+ def authenticated?
25
+ begin
26
+ if has_logged_in?
27
+ true
28
+ else
29
+ auth = TurksatkabloCli::OnlineOperations::Auth.instance
30
+ set_login_data(auth)
31
+
32
+ if has_logged_in?
33
+ true
34
+ else
35
+ user_authenticated? if @fail_login_attempt == 0
36
+ end
37
+ end
38
+ rescue Exception => e
39
+ false
40
+ end
41
+
42
+ end
43
+
44
+ def get_login
45
+ cli = HighLine.new
46
+
47
+ cli.say("Kablo TV Giriş")
48
+ cli.say("* Bilgileriniz daha sonraki girişleriniz için bilgisayarınızda şifrelenerek saklanacaktır.")
49
+
50
+ cli.choose do |menu|
51
+ menu.prompt = 'Abonesi olduğunuz Türksat hizmetleri ile ilgili giriş türü seçiniz: '
52
+ menu.choices(*@login_type.keys) do |chosen|
53
+
54
+ self.username = cli.ask(@login_type[chosen][:username_label])
55
+ self.password = cli.ask(@login_type[chosen][:password_label]) { |q| q.echo = "*" }
56
+
57
+ self.login_choose = chosen
58
+ self.radio_btn_value = @login_type[chosen][:radio_btn_value]
59
+
60
+ user_authenticated?
61
+ end
62
+ end
63
+ end
64
+
65
+
66
+ def end_session
67
+ @session.driver.quit
68
+ @session = nil
69
+ end
70
+
71
+ def screenshot
72
+ @session.save_screenshot
73
+ end
74
+
75
+ def retry_authenticate
76
+ if @fail_login_attempt == 0
77
+ puts "Türksat Kablo Online İşlemler sayfasına şuan ulaşılamıyor, tekrar deniyoruz..."
78
+ @fail_login_attempt = 1
79
+
80
+ user_authenticated?
81
+ else
82
+ puts "Türksat Kablo Online İşlemler sayfasına şuan ulaşılamıyor."
83
+ false
84
+ end
85
+ end
86
+
87
+ def user_authenticated?
88
+ begin
89
+
90
+ visit_status = @session.visit(Enums::BASE_URL)
91
+
92
+ if visit_status["status"] == 'success' && @session.current_url == Enums::BASE_URL
93
+ @fail_login_attempt = 0
94
+ puts "#{Enums::BASE_URL} adresine erişim başarılı. Giriş yapılıyor..."
95
+
96
+ @session.find(:css, "div.radio-container div:nth-child(#{self.radio_btn_value}) > label").click
97
+ kullanici_id = @session.find('input#KullaniciID')
98
+ kullanici_id.send_keys(self.username)
99
+
100
+ kullanici_sifre = @session.find('input#KullaniciSifre')
101
+ kullanici_sifre.send_keys(self.password)
102
+
103
+ @session.find_link(id: 'Button1').click
104
+
105
+ if @session.current_url == Enums::BASE_URL_SUCCESS
106
+ puts "\nGiriş işlemi başarılı"
107
+ add_line
108
+ self.has_logged_in = true
109
+
110
+ true
111
+ else
112
+ puts "\nGiriş bilgileriniz hatalı, kontrol ederek tekrar deneyiniz."
113
+ add_line
114
+
115
+ get_login
116
+ end
117
+ else
118
+ retry_authenticate
119
+ end
120
+
121
+ rescue Exception => e
122
+ retry_authenticate
123
+ end
124
+ end
125
+
126
+ private
127
+ def set_login_data(auth)
128
+ if auth.login_data.kind_of?(Hash) && !has_login_data?
129
+ self.username = auth.login_data[:username]
130
+ self.password = auth.login_data[:password]
131
+ self.radio_btn_value = auth.login_data[:radio_btn_value]
132
+ end
133
+ end
134
+
135
+ def has_login_data?
136
+ if self.username.nil? || self.password.nil? || self.radio_btn_value.nil?
137
+ false
138
+ else
139
+ true
140
+ end
141
+ end
142
+
143
+ end
144
+ end
145
+ end