forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
restrict_model_test.go
45 lines (36 loc) · 1.32 KB
/
restrict_model_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
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2016 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package apiserver_test
import (
"github.com/juju/errors"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"github.com/juju/juju/apiserver"
"github.com/juju/juju/rpc"
"github.com/juju/juju/testing"
)
type restrictModelSuite struct {
testing.BaseSuite
root rpc.Root
}
var _ = gc.Suite(&restrictModelSuite{})
func (s *restrictModelSuite) SetUpSuite(c *gc.C) {
s.BaseSuite.SetUpSuite(c)
s.root = apiserver.TestingModelOnlyRoot()
}
func (s *restrictModelSuite) TestAllowed(c *gc.C) {
s.assertMethod(c, "Client", clientFacadeVersion, "FullStatus")
s.assertMethod(c, "Pinger", pingerFacadeVersion, "Ping")
s.assertMethod(c, "HighAvailability", highAvailabilityFacadeVersion, "EnableHA")
}
func (s *restrictModelSuite) TestBlocked(c *gc.C) {
caller, err := s.root.FindMethod("ModelManager", modelManagerFacadeVersion, "ListModels")
c.Assert(err, gc.ErrorMatches, `facade "ModelManager" not supported for model API connection`)
c.Assert(errors.IsNotSupported(err), jc.IsTrue)
c.Assert(caller, gc.IsNil)
}
func (s *restrictModelSuite) assertMethod(c *gc.C, facadeName string, version int, method string) {
caller, err := s.root.FindMethod(facadeName, version, method)
c.Check(err, jc.ErrorIsNil)
c.Check(caller, gc.NotNil)
}