#NEWLINE# @ skip_if_disabled #NEWLINE# def test_private_images_notadmin( self ) : #NEWLINE# #INDENT# '\n        Test that we can upload an owned image; that we can manipulate\n        its is_public setting; and that appropriate authorization\n        checks are applied to other (non-admin) users.\n        ' #NEWLINE# self . cleanup ( ) #NEWLINE# self . start_servers ( ) #NEWLINE# image_data = ( '*' * FIVE_KB ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'Content-Type' : 'application/octet-stream' , #NEWLINE# 'X-Auth-Token' : keystone_utils . pattieblack_token , #NEWLINE# 'X-Image-Meta-Name' : 'Image1' , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images' % ( '0.0.0.0' , self . api_port ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'POST' , headers = headers , body = image_data ) #NEWLINE# self . assertEqual ( response . status , 201 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# self . assertEqual ( data [ 'image' ] [ 'size' ] , FIVE_KB ) #NEWLINE# self . assertEqual ( data [ 'image' ] [ 'name' ] , 'Image1' ) #NEWLINE# self . assertEqual ( data [ 'image' ] [ 'is_public' ] , False ) #NEWLINE# self . assertEqual ( data [ 'image' ] [ 'owner' ] , keystone_utils . pattieblack_id ) #NEWLINE# image_id = data [ 'image' ] [ 'id' ] #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images' % ( '0.0.0.0' , self . api_port ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'GET' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# self . assertEqual ( content , '{"images": []}' ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/detail' % ( '0.0.0.0' , self . api_port ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'GET' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# self . assertEqual ( content , '{"images": []}' ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'HEAD' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 404 ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'GET' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 404 ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# 'X-Image-Meta-Is-Public' : 'True' , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'PUT' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 404 ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# 'X-Image-Meta-Owner' : 'froggy' , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'PUT' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 404 ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'DELETE' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 404 ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . pattieblack_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images' % ( '0.0.0.0' , self . api_port ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'GET' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# self . assertEqual ( len ( data [ 'images' ] ) , 1 ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'id' ] , image_id ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'size' ] , FIVE_KB ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'name' ] , 'Image1' ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . pattieblack_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/detail' % ( '0.0.0.0' , self . api_port ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'GET' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# self . assertEqual ( len ( data [ 'images' ] ) , 1 ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'size' ] , FIVE_KB ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'name' ] , 'Image1' ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'is_public' ] , False ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'owner' ] , keystone_utils . pattieblack_id ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . pattieblack_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'HEAD' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# self . assertEqual ( response [ 'x-image-meta-name' ] , 'Image1' ) #NEWLINE# self . assertEqual ( response [ 'x-image-meta-is_public' ] , 'False' ) #NEWLINE# self . assertEqual ( response [ 'x-image-meta-owner' ] , keystone_utils . pattieblack_id ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . pattieblack_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'GET' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# self . assertEqual ( content , ( '*' * FIVE_KB ) ) #NEWLINE# self . assertEqual ( response [ 'x-image-meta-name' ] , 'Image1' ) #NEWLINE# self . assertEqual ( response [ 'x-image-meta-is_public' ] , 'False' ) #NEWLINE# self . assertEqual ( response [ 'x-image-meta-owner' ] , keystone_utils . pattieblack_id ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . pattieblack_token , #NEWLINE# 'X-Image-Meta-Is-Public' : 'True' , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'PUT' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# self . assertEqual ( data [ 'image' ] [ 'name' ] , 'Image1' ) #NEWLINE# self . assertEqual ( data [ 'image' ] [ 'is_public' ] , True ) #NEWLINE# self . assertEqual ( data [ 'image' ] [ 'owner' ] , keystone_utils . pattieblack_id ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . pattieblack_token , #NEWLINE# 'X-Image-Meta-Owner' : 'froggy' , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'PUT' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# self . assertEqual ( data [ 'image' ] [ 'name' ] , 'Image1' ) #NEWLINE# self . assertEqual ( data [ 'image' ] [ 'is_public' ] , True ) #NEWLINE# self . assertEqual ( data [ 'image' ] [ 'owner' ] , keystone_utils . pattieblack_id ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images' % ( '0.0.0.0' , self . api_port ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'GET' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# self . assertEqual ( len ( data [ 'images' ] ) , 1 ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'id' ] , image_id ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'size' ] , FIVE_KB ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'name' ] , 'Image1' ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/detail' % ( '0.0.0.0' , self . api_port ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'GET' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# self . assertEqual ( len ( data [ 'images' ] ) , 1 ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'id' ] , image_id ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'size' ] , FIVE_KB ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'name' ] , 'Image1' ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'is_public' ] , True ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'owner' ] , keystone_utils . pattieblack_id ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'HEAD' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# self . assertEqual ( response [ 'x-image-meta-name' ] , 'Image1' ) #NEWLINE# self . assertEqual ( response [ 'x-image-meta-is_public' ] , 'True' ) #NEWLINE# self . assertEqual ( response [ 'x-image-meta-owner' ] , keystone_utils . pattieblack_id ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'GET' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# self . assertEqual ( content , ( '*' * FIVE_KB ) ) #NEWLINE# self . assertEqual ( response [ 'x-image-meta-name' ] , 'Image1' ) #NEWLINE# self . assertEqual ( response [ 'x-image-meta-is_public' ] , 'True' ) #NEWLINE# self . assertEqual ( response [ 'x-image-meta-owner' ] , keystone_utils . pattieblack_id ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# 'X-Image-Meta-Is-Public' : 'True' , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'PUT' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 404 ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# 'X-Image-Meta-Owner' : 'froggy' , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , headers ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'PUT' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 404 ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . froggy_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'DELETE' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 404 ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'X-Auth-Token' : keystone_utils . pattieblack_token , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , image_id ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'DELETE' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# self . stop_servers ( )