github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/apiserver/restrict_upgrades_test.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package apiserver_test 5 6 import ( 7 "github.com/juju/errors" 8 jc "github.com/juju/testing/checkers" 9 gc "gopkg.in/check.v1" 10 11 "github.com/juju/juju/apiserver" 12 "github.com/juju/juju/apiserver/params" 13 "github.com/juju/juju/testing" 14 ) 15 16 type restrictUpgradesSuite struct { 17 testing.BaseSuite 18 } 19 20 var _ = gc.Suite(&restrictUpgradesSuite{}) 21 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) 28 } 29 checkAllowed("Client", "FullStatus") 30 checkAllowed("Client", "AbortCurrentUpgrade") 31 checkAllowed("SSHClient", "PublicAddress") 32 checkAllowed("SSHClient", "Proxy") 33 checkAllowed("Pinger", "Ping") 34 } 35 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) 41 }