blob: 7c0e84eae6bef9083792aee96b9e8f8a35682af2 [file] [log] [blame]
jrperritt3d966162016-06-06 14:08:54 -05001package testing
Jon Perritt3ec6cfd2014-10-06 16:49:48 -05002
3import (
4 "testing"
5
jrperritt3d966162016-06-06 14:08:54 -05006 "github.com/gophercloud/gophercloud"
Jon Perritt27249f42016-02-18 10:35:59 -06007 th "github.com/gophercloud/gophercloud/testhelper"
Jon Perritt3ec6cfd2014-10-06 16:49:48 -05008)
9
10func TestAuthenticatedHeaders(t *testing.T) {
jrperritt3d966162016-06-06 14:08:54 -050011 p := &gophercloud.ProviderClient{
Jon Perritt3ec6cfd2014-10-06 16:49:48 -050012 TokenID: "1234",
13 }
14 expected := map[string]string{"X-Auth-Token": "1234"}
15 actual := p.AuthenticatedHeaders()
16 th.CheckDeepEquals(t, expected, actual)
17}
Jon Perritt2b5e3e12015-02-13 12:15:08 -070018
19func TestUserAgent(t *testing.T) {
jrperritt3d966162016-06-06 14:08:54 -050020 p := &gophercloud.ProviderClient{}
Jon Perritt2b5e3e12015-02-13 12:15:08 -070021
Jamie Hannafordb134f4c2015-04-07 12:05:18 +020022 p.UserAgent.Prepend("custom-user-agent/2.4.0")
Jon Perrittc7a79832016-02-18 12:35:54 -060023 expected := "custom-user-agent/2.4.0 gophercloud/2.0.0"
Jon Perritt2b5e3e12015-02-13 12:15:08 -070024 actual := p.UserAgent.Join()
25 th.CheckEquals(t, expected, actual)
26
Jamie Hannafordb134f4c2015-04-07 12:05:18 +020027 p.UserAgent.Prepend("another-custom-user-agent/0.3.0", "a-third-ua/5.9.0")
Jon Perrittc7a79832016-02-18 12:35:54 -060028 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 Perritt2b5e3e12015-02-13 12:15:08 -070029 actual = p.UserAgent.Join()
30 th.CheckEquals(t, expected, actual)
31
jrperritt3d966162016-06-06 14:08:54 -050032 p.UserAgent = gophercloud.UserAgent{}
Jon Perrittc7a79832016-02-18 12:35:54 -060033 expected = "gophercloud/2.0.0"
Jon Perritt2b5e3e12015-02-13 12:15:08 -070034 actual = p.UserAgent.Join()
35 th.CheckEquals(t, expected, actual)
36}