github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/cloud/whitelist_test.go (about)

     1  // Copyright 2019 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package cloud_test
     5  
     6  import (
     7  	jc "github.com/juju/testing/checkers"
     8  	gc "gopkg.in/check.v1"
     9  
    10  	"github.com/juju/juju/cloud"
    11  )
    12  
    13  func (s *cloudSuite) TestWhitelistString(c *gc.C) {
    14  	c.Assert((&cloud.WhiteList{}).String(), gc.Equals, "empty whitelist")
    15  	c.Assert(cloud.CurrentWhiteList().String(), gc.Equals, `
    16   - controller cloud type "kubernetes" supports [lxd maas openstack]
    17   - controller cloud type "lxd" supports [lxd maas openstack]
    18   - controller cloud type "maas" supports [maas openstack]
    19   - controller cloud type "openstack" supports [openstack]`[1:])
    20  }
    21  
    22  func (s *cloudSuite) TestCheckWhitelistSuccess(c *gc.C) {
    23  	c.Assert(cloud.CurrentWhiteList().Check("maas", "maas"), jc.ErrorIsNil)
    24  }
    25  
    26  func (s *cloudSuite) TestCheckWhitelistFail(c *gc.C) {
    27  	c.Assert(cloud.CurrentWhiteList().Check("ec2", "maas"), gc.ErrorMatches, `
    28  controller cloud type "ec2" is not whitelisted, current whitelist: 
    29   - controller cloud type "kubernetes" supports \[lxd maas openstack\]
    30   - controller cloud type "lxd" supports \[lxd maas openstack\]
    31   - controller cloud type "maas" supports \[maas openstack\]
    32   - controller cloud type "openstack" supports \[openstack\]`[1:])
    33  
    34  	c.Assert(cloud.CurrentWhiteList().Check("openstack", "ec2"), gc.ErrorMatches,
    35  		`cloud type "ec2" is not whitelisted for controller cloud type "openstack", current whitelist: \[openstack\]`)
    36  }