745
def test_glance_cli(self):
747
Test that we can upload an owned image; that we can manipulate
748
its is_public setting; and that appropriate authorization
749
checks are applied to other (non-admin) users.
747
Clear environment to ensure that pre-existing $OS_* variables
748
do not leak into test.
751
super(TestPrivateImagesCli, self).setUp()
753
def _do_test_glance_cli(self, cmd):
755
Test that we can upload an owned image with a given command line;
756
that we can manipulate its is_public setting; and that appropriate
757
authorization checks are applied to other (non-admin) users.
752
760
self.start_servers()
754
# Add a non-public image
755
cmd = ("echo testdata | bin/glance --port=%d --auth_token=%s add "
757
(self.api_port, keystone_utils.pattieblack_token))
758
exitcode, out, err = execute(cmd)
762
# Add a non-public image using the given glance command line
763
exitcode, out, err = execute("echo testdata | %s" % cmd)
760
765
self.assertEqual(0, exitcode)
761
766
image_id = out.strip()[25:]
833
838
self.assertEqual(response['x-image-meta-owner'], '')
835
840
self.stop_servers()
842
def _clear_os_env(self):
843
os.environ.pop('OS_AUTH_URL', None)
844
os.environ.pop('OS_AUTH_STRATEGY', None)
845
os.environ.pop('OS_AUTH_USER', None)
846
os.environ.pop('OS_AUTH_KEY', None)
849
def test_glance_cli_noauth_strategy(self):
851
Test the CLI with the noauth strategy defaulted to.
853
cmd = ("bin/glance --port=%d --auth_token=%s add name=MyImage" %
854
(self.api_port, keystone_utils.pattieblack_token))
855
self._do_test_glance_cli(cmd)
858
def test_glance_cli_keystone_strategy_switches(self):
860
Test the CLI with the keystone (v1) strategy enabled via
861
command line switches.
863
substitutions = (self.api_port, self.auth_port, 'keystone',
864
'pattieblack', 'secrete')
865
cmd = ("bin/glance --port=%d --auth_url=http://localhost:%d/v1.0 "
866
"--auth_strategy=%s --username=%s --password=%s "
867
" add name=MyImage" % substitutions)
868
self._do_test_glance_cli(cmd)
871
def test_glance_cli_keystone_strategy_environment(self):
873
Test the CLI with the keystone strategy enabled via
874
environment variables.
876
os.environ['OS_AUTH_URL'] = 'http://localhost:%d/v1.0' % self.auth_port
877
os.environ['OS_AUTH_STRATEGY'] = 'keystone'
878
os.environ['OS_AUTH_USER'] = 'pattieblack'
879
os.environ['OS_AUTH_KEY'] = 'secrete'
880
cmd = "bin/glance --port=%d add name=MyImage" % self.api_port
881
self._do_test_glance_cli(cmd)