Skip to content

Commit d529347

Browse files
authored
Julia07fixes (#20)
* Increase version for Femtocleaner * femtocleaning * Fix tests * Update appveyor.yml
1 parent 7e2fd9e commit d529347

File tree

4 files changed

+58
-141
lines changed

4 files changed

+58
-141
lines changed

REQUIRE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
julia 0.7-alpha
2-
FactCheck
32
MbedTLS
43
HTTP 0.6.1

appveyor.yml

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
environment:
22
matrix:
3-
#- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
#- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
5-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
7-
8-
## uncomment the following lines to allow failures on nightly julia
9-
## (tests will run but not make your overall status red)
10-
#matrix:
11-
# allow_failures:
12-
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
13-
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 0.7
4+
- julia_version: 1
5+
- julia_version: nightly
6+
7+
platform:
8+
- x86 # 32-bit
9+
- x64 # 64-bit
10+
11+
# # Uncomment the following lines to allow failures on nightly julia
12+
# # (tests will run but not make your overall status red)
13+
# matrix:
14+
# allow_failures:
15+
# - julia_version: latest
1416

1517
branches:
1618
only:
@@ -24,24 +26,18 @@ notifications:
2426
on_build_status_changed: false
2527

2628
install:
27-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
28-
# If there's a newer build queued for the same PR, cancel this one
29-
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
30-
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
31-
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
32-
throw "There are newer queued builds for this pull request, failing early." }
33-
# Download most recent Julia Windows binary
34-
- ps: (new-object net.webclient).DownloadFile(
35-
$env:JULIA_URL,
36-
"C:\projects\julia-binary.exe")
37-
# Run installer silently, output to C:\projects\julia
38-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
29+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
3930

4031
build_script:
41-
# Need to convert from shallow to complete for Pkg.clone to work
42-
- IF EXIST .git\shallow (git fetch --unshallow)
43-
- C:\projects\julia\bin\julia -e "versioninfo();
44-
Pkg.clone(pwd(), \"OAuth\"); Pkg.build(\"OAuth\")"
32+
- echo "%JL_BUILD_SCRIPT%"
33+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
4534

4635
test_script:
47-
- C:\projects\julia\bin\julia -e "Pkg.test(\"OAuth\")"
36+
- echo "%JL_TEST_SCRIPT%"
37+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
38+
39+
# # Uncomment to support code coverage upload. Should only be enabled for packages
40+
# # which would have coverage gaps without running on Windows
41+
# on_success:
42+
# - echo "%JL_CODECOV_SCRIPT%"
43+
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"

src/OAuth.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ __precompile__()
22

33
module OAuth
44

5-
using HTTP, MbedTLS
5+
using HTTP, MbedTLS, Base64, Random
66

77
export
88
oauth_timestamp,

test/runtests.jl

Lines changed: 33 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,40 @@
1-
using OAuth
2-
using FactCheck
3-
4-
facts("oauth_timestamp") do
5-
context("returns a string") do
6-
@fact typeof(oauth_timestamp()) <: AbstractString --> true
7-
end
8-
9-
context("returns a value representing a time after 2014-01-25 20:25:00") do
10-
@fact parse(Int, oauth_timestamp()) > 1422235471 --> true
11-
end
12-
end
13-
14-
facts("ouath_nonce") do
15-
context("returns a string") do
16-
@fact typeof(oauth_nonce(15)) <: AbstractString --> true
17-
end
18-
19-
context("with a length equal to the parameter length") do
20-
@fact length(oauth_nonce(15)) --> 15
21-
@fact length(oauth_nonce(20)) --> 20
22-
@fact length(oauth_nonce(25)) --> 25
23-
@fact length(oauth_nonce(30)) --> 30
24-
@fact length(oauth_nonce(32)) --> 32
25-
end
26-
end
27-
28-
facts("oauth_sign_hmac_sha1") do
29-
context("provides a consistent string") do
30-
expected = "dR8PcWvTl2FyvVM417iTe/p1XV8="
31-
@fact oauth_sign_hmac_sha1("randy", "zwitch") --> expected
32-
end
33-
end
34-
35-
facts("oauth_signing_key") do
36-
context("returns a concatenation of values, seperated by &") do
37-
result = oauth_signing_key("9djdj82h48djs9d2", "kkk9d7dh3k39sjv7")
38-
expected = "9djdj82h48djs9d2&kkk9d7dh3k39sjv7"
39-
@fact result --> expected
40-
end
41-
end
42-
43-
facts("oauth_signature_base_string") do
44-
context("returns a concatinated and percent-encoded string") do
45-
result = oauth_signature_base_string(
46-
"POST", "http://example.com", "?julia=fast&lang=elegant"
47-
)
48-
expected = "POST&http%3A%2F%2Fexample.com&%3Fjulia%3Dfast%26lang%3Delegant"
49-
@fact result --> expected
50-
end
51-
end
52-
53-
facts("oauth_percent_encode_keys!") do
54-
context("replaces un-encoded keys with their encoded versions") do
55-
params = Dict("badkey!" => "value", "goodkey" => "value")
56-
expected = Dict("badkey%21" => "value", "goodkey" => "value")
57-
58-
@fact oauth_percent_encode_keys!(params) --> expected
59-
end
60-
end
61-
62-
facts("oauth_serialize_url_parameters") do
63-
context("returns an & concatinated string of key=value") do
64-
params = Dict("language" => "julia", "result" => "awesome")
65-
expected = "language=julia&result=awesome"
66-
@fact oauth_serialize_url_parameters(params) --> expected
67-
end
68-
end
69-
70-
facts("encodeURI!") do
71-
context("escapes all values in the parameters that are strings") do
72-
params = Dict("iv" => 10, "s" => "value!")
73-
expected = Dict("iv" => 10, "s" => "value%21")
74-
75-
@fact encodeURI!(params) --> expected
76-
end
77-
end
78-
79-
facts("oauth_body_hash_encode") do
80-
context("returns the base64 encoded SHA1 digest of the data") do
81-
result = oauth_body_hash_encode("Hello, World!")
82-
expected = "CgqfKmdylCVXq1NV12r0Qvj2XgE="
83-
@fact result --> expected
84-
end
85-
end
86-
87-
facts("oauth_body_hash_data") do
88-
context("returns a string of the oauth_body_hash key-value pair ") do
89-
result = oauth_body_hash_data("Hello, World!")
90-
encoded_hash = "CgqfKmdylCVXq1NV12r0Qvj2XgE="
91-
expected = "oauth_body_hash=$encoded_hash"
92-
93-
@fact result --> expected
94-
end
95-
end
96-
97-
facts("oauth_body_hash_file") do
98-
context("returns a string of the oauth_body_hash key-value pair ") do
99-
test_file = joinpath(dirname(@__FILE__), "auth_body_hash_file.txt")
100-
result = oauth_body_hash_file(test_file)
101-
encoded_hash = "CgqfKmdylCVXq1NV12r0Qvj2XgE="
102-
expected = "oauth_body_hash=$encoded_hash"
103-
104-
@fact result --> expected
105-
end
106-
end
1+
using OAuth, Test
1072

1083

109-
#TODO
110-
#oauth_header()
4+
@test typeof(oauth_timestamp()) <: AbstractString
1115

6+
@test parse(Int, oauth_timestamp()) > 1422235471
1127

8+
@test typeof(oauth_nonce(15)) <: AbstractString
1139

114-
#TODO
115-
#oauth_request_resource()
10+
@test length(oauth_nonce(15)) == 15
11+
@test length(oauth_nonce(20)) == 20
12+
@test length(oauth_nonce(25)) == 25
13+
@test length(oauth_nonce(30)) == 30
14+
@test length(oauth_nonce(32)) == 32
15+
16+
@test oauth_sign_hmac_sha1("randy", "zwitch") == "dR8PcWvTl2FyvVM417iTe/p1XV8="
17+
18+
@test oauth_signing_key("9djdj82h48djs9d2", "kkk9d7dh3k39sjv7") == "9djdj82h48djs9d2&kkk9d7dh3k39sjv7"
19+
20+
@test oauth_signature_base_string("POST", "http://example.com", "?julia=fast&lang=elegant") ==
21+
"POST&http%3A%2F%2Fexample.com&%3Fjulia%3Dfast%26lang%3Delegant"
22+
23+
@test oauth_percent_encode_keys!(Dict("badkey!" => "value", "goodkey" => "value")) == Dict("badkey%21" => "value", "goodkey" => "value")
24+
25+
@test oauth_serialize_url_parameters(Dict("language" => "julia", "result" => "awesome")) == "language=julia&result=awesome"
11626

27+
@test encodeURI!(Dict("iv" => 10, "s" => "value!")) == Dict("iv" => 10, "s" => "value%21")
11728

118-
FactCheck.exitstatus()
29+
@test oauth_body_hash_encode("Hello, World!") == "CgqfKmdylCVXq1NV12r0Qvj2XgE="
30+
31+
@test oauth_body_hash_data("Hello, World!") == "oauth_body_hash=CgqfKmdylCVXq1NV12r0Qvj2XgE="
32+
33+
test_file = joinpath(dirname(@__FILE__), "auth_body_hash_file.txt")
34+
@test oauth_body_hash_file(test_file) == "oauth_body_hash=CgqfKmdylCVXq1NV12r0Qvj2XgE="
35+
36+
#TODO
37+
#oauth_header()
38+
39+
#TODO
40+
#oauth_request_resource()

0 commit comments

Comments
 (0)