11# The below tests are network-dependent, and actually make calls to GitHub's
22# API. They're all read-only, meaning none of them require authentication.
33
4- testuser = Owner (" julia-github-test-bot" )
5- testuser2 = Owner (" julia-github-test-bot2" )
4+ # testuser = Owner("julia-github-test-bot")
5+ # testuser2 = Owner("julia-github-test-bot2")
66julweb = Owner (" JuliaWeb" , true )
77ghjl = Repo (" JuliaWeb/GitHub.jl" )
88testcommit = Commit (" 627128970bbf09d27c526cb66a17891c389ab914" )
@@ -22,17 +22,37 @@ testuser2_sshkey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCkj86sSo36bkgv+gKp"*
2222
2323hasghobj (obj, items) = any (x -> name (x) == name (obj), items)
2424
25- # This token has public, read-only access, and is required so that our
26- # tests don't get rate-limited. The only way a malicious party could do harm
27- # with this token is if they used it to abuse the rate limit associated with
28- # the token (not too big of a deal). The token is hard-coded in an obsfucated
29- # manner in an attempt to thwart token-stealing crawlers.
30- auth = authenticate (string (circshift ([" bcc" , " 3fc" , " 03a" , " 33e" ,
31- " c09" , " 363" , " 5f1" , " bd3" ,
32- " fc6" , " 77b" , ' 5' , " 9cf" ,
33- " 868" , " 033" ], 3 )... ))
25+ auth = nothing
26+
27+ names = [
28+ " MY_CUSTOM_GITHUB_TOKEN" ,
29+ " GITHUB_TOKEN" ,
30+ ]
31+ for name in names
32+ global auth
33+ if auth === nothing
34+ if haskey (ENV , name)
35+ str = strip (ENV [name])
36+ if ! isempty (str)
37+ @info " Trying token from $name "
38+ auth = authenticate (str)
39+ else
40+ @warn " The $name environment variable is defined, but it is empty or consists only of whitespace"
41+ end
42+ end
43+ end
44+ end
3445
35- @test rate_limit (; auth = auth)[" rate" ][" limit" ] == 5000
46+ if auth === nothing
47+ @warn " Using anonymous GitHub access. If you get rate-limited, please set the MY_CUSTOM_GITHUB_TOKEN or GITHUB_TOKEN env var to an appropriate value."
48+ auth = GitHub. AnonymousAuth ()
49+ end
50+
51+ w = GitHub. whoami (; auth= auth)
52+ @info " " w w. login
53+ testuser = Owner (w. login)
54+
55+ @test rate_limit (; auth = auth)[" rate" ][" limit" ] > 0
3656
3757@testset " Owners" begin
3858 # test GitHub.owner
@@ -45,8 +65,8 @@ auth = authenticate(string(circshift(["bcc", "3fc", "03a", "33e",
4565 @test length (members) > 1
4666
4767 # test GitHub.followers, GitHub.following
48- @test hasghobj (" jrevels" , first (followers (testuser; auth = auth)))
49- @test hasghobj (" jrevels" , first (following (testuser; auth = auth)))
68+ @test_skip hasghobj (" jrevels" , first (followers (testuser; auth = auth))) # TODO FIXME : Fix these tests. https://github.com/JuliaWeb/GitHub.jl/issues/236
69+ @test_skip hasghobj (" jrevels" , first (following (testuser; auth = auth))) # TODO FIXME : Fix these tests. https://github.com/JuliaWeb/GitHub.jl/issues/236
5070
5171 # test GitHub.repos
5272 @test hasghobj (ghjl, first (repos (julweb; auth = auth)))
@@ -188,11 +208,11 @@ end
188208@testset " Activity" begin
189209 # test GitHub.stargazers, GitHub.starred
190210 @test length (first (stargazers (ghjl; auth = auth))) > 10 # every package should fail tests if it's not popular enough :p
191- @test hasghobj (ghjl, first (starred (testuser; auth = auth)))
211+ @test_skip hasghobj (ghjl, first (starred (testuser; auth = auth))) # TODO FIXME : Fix these tests. https://github.com/JuliaWeb/GitHub.jl/issues/237
192212
193213 # test GitHub.watched, GitHub.watched
194- @test hasghobj (testuser, first (watchers (ghjl; auth = auth)))
195- @test hasghobj (ghjl, first (watched (testuser; auth = auth)))
214+ @test_skip hasghobj (testuser, first (watchers (ghjl; auth = auth))) # TODO FIXME : Fix these tests. https://github.com/JuliaWeb/GitHub.jl/issues/237
215+ @test_skip hasghobj (ghjl, first (watched (testuser; auth = auth))) # TODO FIXME : Fix these tests. https://github.com/JuliaWeb/GitHub.jl/issues/237
196216end
197217
198218testbot_key =
321341 @test_throws ArgumentError GitHub. api_uri (GitHub. DEFAULT_API, " /repos/foo/../bar" )
322342 @test_throws ArgumentError GitHub. api_uri (GitHub. DEFAULT_API, " /repos/foo/../bar" )
323343 @test string (GitHub. api_uri (GitHub. DEFAULT_API, " /repos/foo/bar" )) == " https://api.github.com/repos/foo/bar"
324- end
344+ end
0 commit comments