Skip to content

Commit

Permalink
Fixes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
handnot2 committed Jun 5, 2017
1 parent 2461cfc commit 29dc329
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Changelog

### v0.4.0

Fixes:

- Default to "/" when path component not present in URL

### v0.3.0

Fixes:
Expand Down
1 change: 1 addition & 0 deletions lib/sigaws.ex
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ defmodule Sigaws do
{:ok, creds} <- creds_opts(opts_map)
do
%URI{path: req_path, query: qs} = uri = URI.parse(url)
req_path = if req_path, do: req_path, else: "/"

params = (qs || "") |> URI.decode_query() |> Map.merge(params)
headers = headers |> Util.downcase_keys() |> Map.put_new("host", uri_host(uri))
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Sigaws.Mixfile do
use Mix.Project

@version "0.3.1"
@version "0.4.0"
@description """
An Elixir library to sign and verify HTTP requests using AWS Signature V4.
"""
Expand Down
12 changes: 12 additions & 0 deletions test/sigaws_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ defmodule SigawsTest do
assert_all_sig_params(sig_data)
end

test "sign_req: not path component" do
opts = [region: "us-east-1", service: "d3", access_key: "ak1", secret: "sk1"]
assert {:ok, sig_data, _} = Sigaws.sign_req("http://localhost", opts)
assert_all_sig_headers(sig_data)
end

test "sign_url: not path component" do
opts = [region: "gamma-quad", service: "d3", access_key: "ak2", secret: "sk2"]
assert {:ok, sig_data, _} = Sigaws.sign_url("http://localhost", opts)
assert_all_sig_params(sig_data)
end

test "sign_req: valid signed_at UTC" do
now = DateTime.utc_now() |> Map.put(:microsecond, {0, 0})
opts = [region: "gamma-quad", service: "d3", access_key: "ak2", secret: "sk2"]
Expand Down

0 comments on commit 29dc329

Please sign in to comment.