blob: d79d862b2cf93837123b65ccccb4b54bc764e94e [file] [log] [blame]
Jon Perritt3ec6cfd2014-10-06 16:49:48 -05001package gophercloud
2
3import (
4 "testing"
5
6 th "github.com/rackspace/gophercloud/testhelper"
7)
8
9func TestAuthenticatedHeaders(t *testing.T) {
10 p := &ProviderClient{
11 TokenID: "1234",
12 }
13 expected := map[string]string{"X-Auth-Token": "1234"}
14 actual := p.AuthenticatedHeaders()
15 th.CheckDeepEquals(t, expected, actual)
16}
Jon Perritt2b5e3e12015-02-13 12:15:08 -070017
18func TestUserAgent(t *testing.T) {
19 p := &ProviderClient{}
20
Jamie Hannafordb134f4c2015-04-07 12:05:18 +020021 p.UserAgent.Prepend("custom-user-agent/2.4.0")
22 expected := "custom-user-agent/2.4.0 gophercloud/1.0.0"
Jon Perritt2b5e3e12015-02-13 12:15:08 -070023 actual := p.UserAgent.Join()
24 th.CheckEquals(t, expected, actual)
25
Jamie Hannafordb134f4c2015-04-07 12:05:18 +020026 p.UserAgent.Prepend("another-custom-user-agent/0.3.0", "a-third-ua/5.9.0")
27 expected = "another-custom-user-agent/0.3.0 a-third-ua/5.9.0 custom-user-agent/2.4.0 gophercloud/1.0.0"
Jon Perritt2b5e3e12015-02-13 12:15:08 -070028 actual = p.UserAgent.Join()
29 th.CheckEquals(t, expected, actual)
30
31 p.UserAgent = UserAgent{}
Jamie Hannafordb134f4c2015-04-07 12:05:18 +020032 expected = "gophercloud/1.0.0"
Jon Perritt2b5e3e12015-02-13 12:15:08 -070033 actual = p.UserAgent.Join()
34 th.CheckEquals(t, expected, actual)
35}