octoauth 2.0.0 → 2.0.1
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 +4 -4
- data/.github/exporter.sh +16 -0
- data/.github/workflows/build.yml +13 -22
- data/README.md +1 -1
- data/octoauth.gemspec +4 -4
- metadata +10 -10
- data/spec/octoauth/auth_spec.rb +0 -150
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29b43a20cb61538f2714aebf421f9174aaeec8f443a9535c7e0c14af297c8aa4
|
4
|
+
data.tar.gz: 905f1d586b200888c014aab201b91f139e3c9bc41b1de69a8a31d84eeea6c539
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: febcbe8962325e1c12a9a236bbecb959deb0ddb255f2464bf5d178d7056564e124333db9ddd6def09926e8c9c95afaa9a303b0c25f59695b0bb0959186c36e35
|
7
|
+
data.tar.gz: ce14815044feeff65c30949366186ce53bbab05dd508dd9109f49f374fb627303835cc3a21933e0b04406788c33b4f697830e61ea158caf476a4b70244f482c2
|
data/.github/exporter.sh
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -euo pipefail
|
4
|
+
|
5
|
+
URL="https://exporter.akerl.app/metric"
|
6
|
+
AUTH="Authorization: Bearer $EXPORTER_TOKEN"
|
7
|
+
if [[ "$JOB_STATUS" == "success" ]] ; then
|
8
|
+
VALUE=1
|
9
|
+
else
|
10
|
+
VALUE=0
|
11
|
+
fi
|
12
|
+
BODY="{\"name\":\"gh/${GITHUB_REPOSITORY}\",\"metrics\":[{\"name\":\"ghactions\",\"type\":\"gauge\",\"tags\":{\"repo\":\"${GITHUB_REPOSITORY}\"},\"value\":\"${VALUE}\"}]}"
|
13
|
+
|
14
|
+
echo "$BODY"
|
15
|
+
|
16
|
+
curl -i -XPOST -d "$BODY" -H"$AUTH" "$URL"
|
data/.github/workflows/build.yml
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
+
---
|
1
2
|
name: Build
|
2
|
-
on:
|
3
|
-
pull_request:
|
3
|
+
'on':
|
4
4
|
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
tags:
|
8
|
+
- "**"
|
9
|
+
pull_request_target:
|
5
10
|
jobs:
|
6
11
|
build:
|
7
12
|
name: Build
|
@@ -23,24 +28,10 @@ jobs:
|
|
23
28
|
if: github.ref_type == 'tag'
|
24
29
|
run: bundle exec rake release
|
25
30
|
env:
|
26
|
-
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
|
27
|
-
- name: Post to
|
28
|
-
|
29
|
-
uses: slackapi/slack-github-action@v1.23.0
|
31
|
+
GEM_HOST_API_KEY: "${{ secrets.GEM_HOST_API_KEY }}"
|
32
|
+
- name: Post to hook-exporter
|
33
|
+
run: "./.github/exporter.sh"
|
30
34
|
env:
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
payload: |
|
35
|
-
{
|
36
|
-
"text": "*${{ github.repository }}*\nBuild failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
|
37
|
-
"blocks": [
|
38
|
-
{
|
39
|
-
"type": "section",
|
40
|
-
"text": {
|
41
|
-
"type": "mrkdwn",
|
42
|
-
"text": "*${{ github.repository }}*\nBuild failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
43
|
-
}
|
44
|
-
}
|
45
|
-
]
|
46
|
-
}
|
35
|
+
EXPORTER_TOKEN: "${{ secrets.EXPORTER_TOKEN }}"
|
36
|
+
JOB_STATUS: "${{ job.status }}"
|
37
|
+
if: always() && github.ref == 'refs/heads/main'
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@ octoauth
|
|
2
2
|
=========
|
3
3
|
|
4
4
|
[](https://rubygems.org/gems/octoauth)
|
5
|
-
[](https://github.com/akerl/octoauth/actions)
|
6
6
|
[](https://tldrlegal.com/license/mit-license)
|
7
7
|
|
8
8
|
Authentication wrapper for GitHub's API
|
data/octoauth.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'octoauth'
|
3
|
-
s.version = '2.0.
|
3
|
+
s.version = '2.0.1'
|
4
4
|
|
5
5
|
s.required_ruby_version = '>= 2.6'
|
6
6
|
|
@@ -13,12 +13,12 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.files = `git ls-files`.split
|
15
15
|
|
16
|
-
s.add_dependency 'octokit', '~>
|
16
|
+
s.add_dependency 'octokit', '~> 10.0.0'
|
17
17
|
s.add_dependency 'userinput', '~> 1.0.2'
|
18
18
|
|
19
19
|
s.add_development_dependency 'goodcop', '~> 0.9.7'
|
20
|
-
s.add_development_dependency 'vcr', '~>
|
21
|
-
s.add_development_dependency 'webmock', '~> 3.
|
20
|
+
s.add_development_dependency 'vcr', '~> 6.3.1'
|
21
|
+
s.add_development_dependency 'webmock', '~> 3.25.1'
|
22
22
|
|
23
23
|
s.metadata['rubygems_mfa_required'] = 'true'
|
24
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octoauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Les Aker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 10.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 10.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: userinput
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,34 +58,35 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 6.3.1
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 6.3.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 3.
|
75
|
+
version: 3.25.1
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 3.
|
82
|
+
version: 3.25.1
|
83
83
|
description: Lightweight wrapper to sanely handle OAuth tokens with Octokit
|
84
84
|
email: me@lesaker.org
|
85
85
|
executables: []
|
86
86
|
extensions: []
|
87
87
|
extra_rdoc_files: []
|
88
88
|
files:
|
89
|
+
- ".github/exporter.sh"
|
89
90
|
- ".github/workflows/build.yml"
|
90
91
|
- ".gitignore"
|
91
92
|
- ".rspec"
|
@@ -107,7 +108,6 @@ files:
|
|
107
108
|
- spec/fixtures/cassettes/recreate_token.yml
|
108
109
|
- spec/fixtures/cassettes/requesting_scopes.yml
|
109
110
|
- spec/fixtures/cassettes/write_to_first_file.yml
|
110
|
-
- spec/octoauth/auth_spec.rb
|
111
111
|
- spec/octoauth/configfile_spec.rb
|
112
112
|
- spec/octoauth_spec.rb
|
113
113
|
- spec/spec_helper.rb
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
|
-
rubygems_version: 3.3.
|
134
|
+
rubygems_version: 3.3.27
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: Auth token helper for GitHub API
|
data/spec/octoauth/auth_spec.rb
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
##
|
5
|
-
# Grab creds for setting up VCR
|
6
|
-
LOGIN = ENV['OCTOAUTH_LOGIN'] || 'user'
|
7
|
-
PASSWORD = ENV['OCTOAUTH_PASSWORD'] || 'pw'
|
8
|
-
TWOFACTOR = ENV['OCTOAUTH_TFA'] || '123456'
|
9
|
-
|
10
|
-
describe Octoauth do
|
11
|
-
describe Octoauth::Auth do
|
12
|
-
describe '#initialize' do
|
13
|
-
context 'if the file and note already exist' do
|
14
|
-
it 'loads the existing token' do
|
15
|
-
VCR.use_cassette('load_existing_token') do
|
16
|
-
auth = Octoauth::Auth.new(
|
17
|
-
note: 'existing_token',
|
18
|
-
file: 'spec/examples/existing_token.yml'
|
19
|
-
)
|
20
|
-
expect(auth.token).to eql 'an_existing_token'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
context 'if there is a note conflict' do
|
25
|
-
it 'recreates the token' do
|
26
|
-
VCR.use_cassette('recreate_token') do
|
27
|
-
tokens = (1..2).map do
|
28
|
-
Octoauth::Auth.new(
|
29
|
-
note: 'existing_token',
|
30
|
-
login: LOGIN,
|
31
|
-
password: PASSWORD
|
32
|
-
).token
|
33
|
-
end
|
34
|
-
expect(tokens.first).not_to eql tokens.last
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
context 'if the file does not exist' do
|
39
|
-
it 'use user input to create token' do
|
40
|
-
VCR.use_cassette('create_token') do
|
41
|
-
auth = Octoauth::Auth.new(
|
42
|
-
note: 'create_token',
|
43
|
-
login: LOGIN,
|
44
|
-
password: PASSWORD
|
45
|
-
)
|
46
|
-
expect(auth.token).to eql 'created_token'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
it 'handles users with 2 factor auth enabled' do
|
50
|
-
VCR.use_cassette('handle_two_factor') do
|
51
|
-
auth = Octoauth::Auth.new(
|
52
|
-
note: 'two_factor_token',
|
53
|
-
login: LOGIN,
|
54
|
-
password: PASSWORD,
|
55
|
-
twofactor: TWOFACTOR
|
56
|
-
)
|
57
|
-
expect(auth.token).to eql '2fa_required_token'
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
it 'supports alternate endpoints' do
|
62
|
-
VCR.use_cassette('alternate_endpoints') do
|
63
|
-
auth = Octoauth::Auth.new(
|
64
|
-
note: 'alternate_endpoint',
|
65
|
-
login: LOGIN,
|
66
|
-
password: PASSWORD,
|
67
|
-
api_endpoint: 'https://example.org/api/v3/'
|
68
|
-
)
|
69
|
-
expect(auth.token).to eql 'created_token'
|
70
|
-
end
|
71
|
-
end
|
72
|
-
it 'supports requesting scopes' do
|
73
|
-
VCR.use_cassette('requesting_scopes') do
|
74
|
-
auth = Octoauth::Auth.new(
|
75
|
-
note: 'requesting_scopes',
|
76
|
-
login: LOGIN,
|
77
|
-
password: PASSWORD,
|
78
|
-
scopes: %w[gist delete_repo]
|
79
|
-
)
|
80
|
-
expect(auth.token).to eql 'token_with_scopes'
|
81
|
-
end
|
82
|
-
end
|
83
|
-
it 'supports autosaving the config file' do
|
84
|
-
VCR.use_cassette('autosaving_config_file') do
|
85
|
-
FileUtils.rm_f 'spec/examples/autosave.yml'
|
86
|
-
Octoauth::Auth.new(
|
87
|
-
note: 'autosave_test',
|
88
|
-
file: 'spec/examples/autosave.yml',
|
89
|
-
login: LOGIN,
|
90
|
-
password: PASSWORD,
|
91
|
-
autosave: true
|
92
|
-
)
|
93
|
-
new_auth = Octoauth::Auth.new(
|
94
|
-
note: 'autosave_test',
|
95
|
-
file: 'spec/examples/autosave.yml'
|
96
|
-
)
|
97
|
-
expect(new_auth.token).to eql 'autosaved_token'
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
context 'when given multiple file paths' do
|
102
|
-
context 'when the first file exists' do
|
103
|
-
it 'reads the first file' do
|
104
|
-
auth = Octoauth::Auth.new(
|
105
|
-
note: 'existing_token',
|
106
|
-
files: ['spec/examples/existing_token.yml', 'bogus.yml']
|
107
|
-
)
|
108
|
-
expect(auth.token).to eql 'an_existing_token'
|
109
|
-
end
|
110
|
-
end
|
111
|
-
context 'when the first file does not exist' do
|
112
|
-
context 'when the second file exists' do
|
113
|
-
it 'reads the second file' do
|
114
|
-
auth = Octoauth::Auth.new(
|
115
|
-
note: 'existing_token',
|
116
|
-
files: ['bogus.yml', 'spec/examples/existing_token.yml']
|
117
|
-
)
|
118
|
-
expect(auth.token).to eql 'an_existing_token'
|
119
|
-
end
|
120
|
-
end
|
121
|
-
context 'when the second file does not exist' do
|
122
|
-
it 'reads nil from the first file' do
|
123
|
-
auth = Octoauth::Auth.new(
|
124
|
-
note: 'nonexistent_token',
|
125
|
-
files: ['nil.yml', 'nil2.yml']
|
126
|
-
)
|
127
|
-
expect(auth.send(:config).token).to be_nil
|
128
|
-
end
|
129
|
-
it 'writes to the first file' do
|
130
|
-
VCR.use_cassette('write_to_first_file') do
|
131
|
-
FileUtils.rm_f 'spec/examples/write_first_test.yml'
|
132
|
-
auth = Octoauth::Auth.new(
|
133
|
-
note: 'write_first_test',
|
134
|
-
files: ['spec/examples/write_first_test.yml', 'bogus.yml'],
|
135
|
-
login: LOGIN,
|
136
|
-
password: PASSWORD
|
137
|
-
)
|
138
|
-
auth.save
|
139
|
-
new_auth = Octoauth::Auth.new(
|
140
|
-
note: 'write_first_test',
|
141
|
-
file: 'spec/examples/write_first_test.yml'
|
142
|
-
)
|
143
|
-
expect(new_auth.token).to eql 'write_first_test_token'
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|