getauthtoken 0.4.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: 68681b938373b176e145a551cb269a38a25d6730685b0fc9a42ce2613a06151a
4
+ data.tar.gz: 10e76d40cf115b6a99b823a1238c769d3ff2ad54b2cfd660b5d14a1fb4d6ecd2
5
+ SHA512:
6
+ metadata.gz: b4159644067d1c8e793ef0dd778681854db8867b687f970903c082d0222b4588e60a36347569dc8fc97ef7d108d783998f2509767ac909473da1958d582055ab
7
+ data.tar.gz: a7081d399e1b1f6393d82647b1f53e1f65fe8b6d0e368ea06783930ea5c0a429f0d3c117e82e1418f3ed612de6848582c97365cfb12462c4fbf15447a12e66ba
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 2.0.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in getauthtoken.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,60 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ getauthtoken (0.3.0)
5
+ http (~> 4.2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ diff-lcs (1.3)
13
+ domain_name (0.5.20190701)
14
+ unf (>= 0.0.5, < 1.0.0)
15
+ ffi (1.11.3)
16
+ ffi-compiler (1.0.1)
17
+ ffi (>= 1.0.0)
18
+ rake
19
+ http (4.2.0)
20
+ addressable (~> 2.3)
21
+ http-cookie (~> 1.0)
22
+ http-form_data (~> 2.0)
23
+ http-parser (~> 1.2.0)
24
+ http-cookie (1.0.3)
25
+ domain_name (~> 0.5)
26
+ http-form_data (2.1.1)
27
+ http-parser (1.2.1)
28
+ ffi-compiler (>= 1.0, < 2.0)
29
+ minitest (5.13.0)
30
+ public_suffix (4.0.1)
31
+ rake (10.5.0)
32
+ rspec (3.9.0)
33
+ rspec-core (~> 3.9.0)
34
+ rspec-expectations (~> 3.9.0)
35
+ rspec-mocks (~> 3.9.0)
36
+ rspec-core (3.9.0)
37
+ rspec-support (~> 3.9.0)
38
+ rspec-expectations (3.9.0)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.9.0)
41
+ rspec-mocks (3.9.0)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.9.0)
44
+ rspec-support (3.9.0)
45
+ unf (0.1.4)
46
+ unf_ext
47
+ unf_ext (0.0.7.6)
48
+
49
+ PLATFORMS
50
+ ruby
51
+
52
+ DEPENDENCIES
53
+ bundler (~> 2.0)
54
+ getauthtoken!
55
+ minitest (~> 5.0)
56
+ rake (~> 10.0)
57
+ rspec (~> 3.9.0)
58
+
59
+ BUNDLED WITH
60
+ 2.0.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Dylan Irlbeck
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,54 @@
1
+ # Getauthtoken
2
+
3
+ `getauthtoken` is a small command line utility to acquire an authorization token from [Xaptum](https://dev.xaptum.io). It's intended to speed up the process of testing API's, since an authorization token is required as a header in every request and new tokens are generated every four hours.
4
+
5
+ Running `getauthtoken` from your command line after installation (see below) will always give the current token.
6
+
7
+ ## Installation
8
+
9
+ First, clone the repository and install the gem locally. You may need to `sudo gem install` here.
10
+
11
+ ```shell
12
+ $ git clone https://github.com/dylanirlbeck/getauthtoken.git
13
+ $ cd getauthtoken
14
+ $ gem install getauthtoken-0.3.0.gem
15
+ ```
16
+
17
+ Second, we'll need to create JSON file that stores your Xaptum credentials. `getauthtoken` will always use the credentials in this file to acquire your auth token. In your `$HOME` directory, create the file `.xaptum_credentials.json` with the following structure:
18
+
19
+ ```json
20
+ {
21
+ "username": "<YOUR_USERNAME>",
22
+ "password": "<YOUR_PASSWORD>"
23
+ }
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ Simply run `getauthtoken` from the command line. The token should then appear and get copied to your clipboard.
29
+
30
+ Note that you do **not** have to be in the `getauthtoken` project directory (that you cloned earlier) to use this utility.
31
+
32
+ ```shell
33
+ $ getauthtoken
34
+ Authenticating with Xaptum...
35
+ Your token is <TOKEN>. It has been copied to the clipboard.
36
+ ```
37
+
38
+ ## Development
39
+
40
+ Write tests, pass tests, bump version, pull request.
41
+
42
+ Running the tests
43
+
44
+ ```shell
45
+ $ rake test
46
+ ```
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dylanirlbeck/getauthtoken.
51
+
52
+ ## License
53
+
54
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/getauthtoken ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ require 'getauthtoken'
3
+
4
+ puts "Authenticating with Xaptum..."
5
+ token = Getauthtoken::authenticate()
6
+ Getauthtoken::pbcopy(token)
7
+ puts "Your token is #{token}. It has been copied to the clipboard."
@@ -0,0 +1,37 @@
1
+ lib = File.expand_path("lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "getauthtoken/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "getauthtoken"
7
+ spec.version = Getauthtoken::VERSION
8
+ spec.authors = ["Dylan Irlbeck"]
9
+ spec.email = ["irlbeck2@illinois.edu"]
10
+
11
+ spec.summary = "Acquire a Xaptum API authorization token"
12
+ spec.description = "Small CLI utility to acquire a Xaptum API authentication token and copy into your clipboard."
13
+ spec.homepage = "https://xaptum.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/dylanirlbeck/getauthtoken"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ # spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ # `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
+ f.match(%r{^(test|spec|features)/})
25
+
26
+ end
27
+ spec.bindir = "bin"
28
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "http", "~> 4.2.0"
32
+
33
+ spec.add_development_dependency "bundler", "~> 2.0"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "minitest", "~> 5.0"
36
+ spec.add_development_dependency "rspec", "~> 3.9.0"
37
+ end
@@ -0,0 +1,35 @@
1
+ require "getauthtoken/version"
2
+ require "json"
3
+ require "http"
4
+
5
+ module Getauthtoken
6
+ BASE_URL = 'https://dev.xaptum.io/api/xcr/v2/xauth'
7
+
8
+ def self.authenticate()
9
+ credentials = get_credentials()
10
+ return post_credentials(credentials)
11
+ end
12
+
13
+ def self.get_credentials()
14
+ file = File.open(File.expand_path("~/.xaptum_credentials.json"))
15
+ data = JSON.load file
16
+ file.close
17
+ return data
18
+ end
19
+
20
+ def self.post_credentials(credentials)
21
+ hash = { "username" => credentials["username"], "token" => credentials["password"]}
22
+ json = JSON.generate(hash)
23
+ response = HTTP.headers("Content-Type": "application/json", "Accept": "application/json")
24
+ .post(BASE_URL, body: json)
25
+
26
+ return response.code == 200 ? JSON.parse(response)["data"][0]["token"] : nil
27
+ end
28
+
29
+ def self.pbcopy(token)
30
+ IO.popen('pbcopy', 'w') { |f| f << token }
31
+ token
32
+ end
33
+
34
+ end
35
+
@@ -0,0 +1,3 @@
1
+ module Getauthtoken
2
+ VERSION = "0.4.0"
3
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: getauthtoken
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ platform: ruby
6
+ authors:
7
+ - Dylan Irlbeck
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-12-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.9.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.9.0
83
+ description: Small CLI utility to acquire a Xaptum API authentication token and copy
84
+ into your clipboard.
85
+ email:
86
+ - irlbeck2@illinois.edu
87
+ executables:
88
+ - getauthtoken
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/getauthtoken
100
+ - getauthtoken.gemspec
101
+ - lib/getauthtoken.rb
102
+ - lib/getauthtoken/version.rb
103
+ homepage: https://xaptum.com
104
+ licenses:
105
+ - MIT
106
+ metadata:
107
+ homepage_uri: https://xaptum.com
108
+ source_code_uri: https://github.com/dylanirlbeck/getauthtoken
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubygems_version: 3.0.3
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Acquire a Xaptum API authorization token
128
+ test_files: []