~gz/goose/novaservice_preserve_negative_ports

« back to all changes in this revision

Viewing changes to identity/userpass_test.go

  • Committer: Ian Booth
  • Date: 2013-02-08 02:23:27 UTC
  • mto: This revision was merged to the branch mainline in revision 68.
  • Revision ID: ian.booth@canonical.com-20130208022327-lpakgw1vv5kpkjmo
Add region matching tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
        c.Assert(auth.Token, Equals, userInfo.Token)
24
24
        c.Assert(auth.TenantId, Equals, userInfo.TenantId)
25
25
}
 
26
 
 
27
// Test that inexact region matches are handled properly.
 
28
func (s *UserPassTestSuite) TestRegionMatch(c *C) {
 
29
        service := identityservice.NewUserPass()
 
30
        service.SetupHTTP(s.Mux)
 
31
        userInfo := service.AddUser("joe-user", "secrets", "tenant")
 
32
        serviceDef := identityservice.Service{"swift", "object-store", []identityservice.Endpoint{
 
33
                identityservice.Endpoint{PublicURL: "http://swift", Region: "RegionOne"},
 
34
        }}
 
35
        service.AddService(serviceDef)
 
36
        serviceDef = identityservice.Service{"nova", "compute", []identityservice.Endpoint{
 
37
                identityservice.Endpoint{PublicURL: "http://nova", Region: "zone1.RegionOne"},
 
38
        }}
 
39
        service.AddService(serviceDef)
 
40
        serviceDef = identityservice.Service{"nova", "compute", []identityservice.Endpoint{
 
41
                identityservice.Endpoint{PublicURL: "http://nova2", Region: "zone2.RegionOne"},
 
42
        }}
 
43
        service.AddService(serviceDef)
 
44
 
 
45
        creds := Credentials{
 
46
                User:    "joe-user",
 
47
                URL:     s.Server.URL + "/tokens",
 
48
                Secrets: "secrets",
 
49
                Region:  "zone1.RegionOne",
 
50
        }
 
51
        var l Authenticator = &UserPass{}
 
52
        auth, err := l.Auth(&creds)
 
53
        c.Assert(err, IsNil)
 
54
        c.Assert(auth.ServiceURLs["object-store"], Equals, "http://swift")
 
55
        c.Assert(auth.ServiceURLs["compute"], Equals, "http://nova")
 
56
        c.Assert(auth.Token, Equals, userInfo.Token)
 
57
        c.Assert(auth.TenantId, Equals, userInfo.TenantId)
 
58
}