-
Notifications
You must be signed in to change notification settings - Fork 0
/
uri_test.go
34 lines (24 loc) · 730 Bytes
/
uri_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package macaroon
import (
"fmt"
"path/filepath"
"testing"
)
func TestNewMacaroonURI(t *testing.T) {
expected := "macaroon:https://sfomuseum.org?duration=PT1M&key=file%3A%2F%2F%2Fusr%2Flocal%2Fsfomuseum%2Fgo-macaroon%2Ffixtures%2Fsigning.key"
abs_path, err := filepath.Abs(".")
if err != nil {
t.Fatalf("Failed to derive absolute path, %v", err)
}
path_key := filepath.Join(abs_path, "fixtures/signing.key")
key_uri := fmt.Sprintf("file:https://%s", path_key)
loc := "sfomuseum.org"
duration := "PT1M"
m_uri, err := NewMacaroonURI(loc, key_uri, duration)
if err != nil {
t.Fatalf("Failed to create new macaroon URI, %v", err)
}
if m_uri != expected {
t.Fatalf("Expected '%s' but got '%s'", expected, m_uri)
}
}