Skip to content

Commit 8793771

Browse files
committed
Don't hard-code a token in the tests.
1 parent ba51450 commit 8793771

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242
${{ runner.os }}-
4343
- uses: julia-actions/julia-buildpkg@v1
4444
- uses: julia-actions/julia-runtest@v1
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4547
- uses: julia-actions/julia-processcoverage@v1
4648
- uses: codecov/codecov-action@v1
4749
with:

test/read_only_api_tests.jl

+9-11
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@ testuser_sshkey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVDBxFza4BmQTCTFeTyK"*
1414

1515
hasghobj(obj, items) = any(x -> name(x) == name(obj), items)
1616

17-
# This token has public, read-only access, and is required so that our
18-
# tests don't get rate-limited. The only way a malicious party could do harm
19-
# with this token is if they used it to abuse the rate limit associated with
20-
# the token (not too big of a deal). The token is hard-coded in an obsfucated
21-
# manner in an attempt to thwart token-stealing crawlers.
22-
auth = authenticate(string(circshift(["bcc", "3fc", "03a", "33e",
23-
"c09", "363", "5f1", "bd3",
24-
"fc6", "77b", '5', "9cf",
25-
"868", "033"], 3)...))
26-
27-
@test rate_limit(; auth = auth)["rate"]["limit"] == 5000
17+
if haskey(ENV, "GITHUB_TOKEN")
18+
@info "Using GitHub token from ENV"
19+
auth = authenticate(ENV["GITHUB_TOKEN"])
20+
@test rate_limit(; auth = auth)["rate"]["limit"] == 5000
21+
else
22+
@warn "Using anonymous GitHub access. If you get rate-limited, please set the GITHUB_TOKEN env var to an appropriate value."
23+
auth = GitHub.AnonymousAuth()
24+
@test rate_limit(; auth = auth)["rate"]["limit"] == 60
25+
end
2826

2927
@testset "Owners" begin
3028
# test GitHub.owner

0 commit comments

Comments
 (0)