jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 1 | package testing |
Jon Perritt | 3ec6cfd | 2014-10-06 16:49:48 -0500 | [diff] [blame] | 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 6 | "github.com/gophercloud/gophercloud" |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame] | 7 | th "github.com/gophercloud/gophercloud/testhelper" |
Jon Perritt | 3ec6cfd | 2014-10-06 16:49:48 -0500 | [diff] [blame] | 8 | ) |
| 9 | |
| 10 | func TestAuthenticatedHeaders(t *testing.T) { |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 11 | p := &gophercloud.ProviderClient{ |
Jon Perritt | 3ec6cfd | 2014-10-06 16:49:48 -0500 | [diff] [blame] | 12 | TokenID: "1234", |
| 13 | } |
| 14 | expected := map[string]string{"X-Auth-Token": "1234"} |
| 15 | actual := p.AuthenticatedHeaders() |
| 16 | th.CheckDeepEquals(t, expected, actual) |
| 17 | } |
Jon Perritt | 2b5e3e1 | 2015-02-13 12:15:08 -0700 | [diff] [blame] | 18 | |
| 19 | func TestUserAgent(t *testing.T) { |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 20 | p := &gophercloud.ProviderClient{} |
Jon Perritt | 2b5e3e1 | 2015-02-13 12:15:08 -0700 | [diff] [blame] | 21 | |
Jamie Hannaford | b134f4c | 2015-04-07 12:05:18 +0200 | [diff] [blame] | 22 | p.UserAgent.Prepend("custom-user-agent/2.4.0") |
Jon Perritt | c7a7983 | 2016-02-18 12:35:54 -0600 | [diff] [blame] | 23 | expected := "custom-user-agent/2.4.0 gophercloud/2.0.0" |
Jon Perritt | 2b5e3e1 | 2015-02-13 12:15:08 -0700 | [diff] [blame] | 24 | actual := p.UserAgent.Join() |
| 25 | th.CheckEquals(t, expected, actual) |
| 26 | |
Jamie Hannaford | b134f4c | 2015-04-07 12:05:18 +0200 | [diff] [blame] | 27 | p.UserAgent.Prepend("another-custom-user-agent/0.3.0", "a-third-ua/5.9.0") |
Jon Perritt | c7a7983 | 2016-02-18 12:35:54 -0600 | [diff] [blame] | 28 | expected = "another-custom-user-agent/0.3.0 a-third-ua/5.9.0 custom-user-agent/2.4.0 gophercloud/2.0.0" |
Jon Perritt | 2b5e3e1 | 2015-02-13 12:15:08 -0700 | [diff] [blame] | 29 | actual = p.UserAgent.Join() |
| 30 | th.CheckEquals(t, expected, actual) |
| 31 | |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 32 | p.UserAgent = gophercloud.UserAgent{} |
Jon Perritt | c7a7983 | 2016-02-18 12:35:54 -0600 | [diff] [blame] | 33 | expected = "gophercloud/2.0.0" |
Jon Perritt | 2b5e3e1 | 2015-02-13 12:15:08 -0700 | [diff] [blame] | 34 | actual = p.UserAgent.Join() |
| 35 | th.CheckEquals(t, expected, actual) |
| 36 | } |