1
// Copyright 2014 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
7
"github.com/juju/errors"
8
jc "github.com/juju/testing/checkers"
11
"github.com/juju/juju/apiserver"
12
"github.com/juju/juju/apiserver/params"
13
"github.com/juju/juju/testing"
16
type restrictUpgradesSuite struct {
20
var _ = gc.Suite(&restrictUpgradesSuite{})
22
func (r *restrictUpgradesSuite) TestAllowedMethods(c *gc.C) {
23
root := apiserver.TestingUpgradingRoot(nil)
24
checkAllowed := func(facade, method string) {
25
caller, err := root.FindMethod(facade, 1, method)
26
c.Check(err, jc.ErrorIsNil)
27
c.Check(caller, gc.NotNil)
29
checkAllowed("Client", "FullStatus")
30
checkAllowed("Client", "AbortCurrentUpgrade")
31
checkAllowed("SSHClient", "PublicAddress")
32
checkAllowed("SSHClient", "Proxy")
33
checkAllowed("Pinger", "Ping")
36
func (r *restrictUpgradesSuite) TestFindDisallowedMethod(c *gc.C) {
37
root := apiserver.TestingUpgradingRoot(nil)
38
caller, err := root.FindMethod("Client", 1, "ModelSet")
39
c.Assert(errors.Cause(err), gc.Equals, params.UpgradeInProgressError)
40
c.Assert(caller, gc.IsNil)