#NEWLINE# def testCORS( self ) : #NEWLINE# #INDENT# testServer . root . api . v1 . dummy = DummyResource ( ) #NEWLINE# resp = self . request ( path = '/dummy/test' ) #NEWLINE# self . assertStatusOk ( resp ) #NEWLINE# self . assertFalse ( ( 'Access-Control-Allow-Origin' in resp . headers ) ) #NEWLINE# self . assertFalse ( ( 'Access-Control-Allow-Credentials' in resp . headers ) ) #NEWLINE# resp = self . request ( path = '/dummy/test' , additionalHeaders = [ ( 'Origin' , 'http://foo.com' ) ] ) #NEWLINE# self . assertStatusOk ( resp ) #NEWLINE# self . assertFalse ( ( 'Access-Control-Allow-Origin' in resp . headers ) ) #NEWLINE# self . model ( 'setting' ) . set ( SettingKey . CORS_ALLOW_ORIGIN , 'http://kitware.com' ) #NEWLINE# resp = self . request ( path = '/dummy/test' , additionalHeaders = [ ( 'Origin' , 'http://foo.com' ) ] ) #NEWLINE# self . assertEqual ( resp . headers [ 'Access-Control-Allow-Origin' ] , 'http://kitware.com' ) #NEWLINE# self . assertEqual ( resp . headers [ 'Access-Control-Allow-Credentials' ] , 'true' ) #NEWLINE# self . model ( 'setting' ) . set ( SettingKey . CORS_ALLOW_METHODS , 'POST' ) #NEWLINE# resp = self . request ( path = '/dummy/test' , method = 'OPTIONS' , additionalHeaders = [ ( 'Origin' , 'http://foo.com' ) ] , isJson = False ) #NEWLINE# self . assertStatusOk ( resp ) #NEWLINE# self . assertEqual ( self . getBody ( resp ) , '' ) #NEWLINE# self . assertEqual ( resp . headers [ 'Access-Control-Allow-Origin' ] , 'http://kitware.com' ) #NEWLINE# self . assertEqual ( resp . headers [ 'Access-Control-Allow-Credentials' ] , 'true' ) #NEWLINE# self . assertEqual ( resp . headers [ 'Access-Control-Allow-Headers' ] , SettingDefault . defaults [ SettingKey . CORS_ALLOW_HEADERS ] ) #NEWLINE# self . assertEqual ( resp . headers [ 'Access-Control-Allow-Methods' ] , 'POST' )