コード例 #1
0
ファイル: test_challenge.py プロジェクト: mbellotti/hdx-ckan
    def test_login_form_send(self):
	"""test if the login form data is received and the environment set correctly"""
	fields = [('repoze.whoplugins.openid.openid','foobar.com')]
	content_type, body = encode_multipart_formdata(fields)

	environ = self.environ
	environ['wsgi.input'] = StringIO(body)
	environ['REQUEST_METHOD'] = 'POST'
	environ['CONTENT_LENGTH'] = len(body)
	environ['CONTENT_TYPE'] = content_type
	environ['PATH_INFO'] = '/login'

	identity = self.plugin.identify(environ)
	self.assertEqual(environ.get('repoze.whoplugins.openid.openid',None), 'foobar.com')
コード例 #2
0
ファイル: test_challenge.py プロジェクト: mbellotti/hdx-ckan
    def test_complete_openid_request(self):
	"""test if the openid request completes"""

	environ = self.environ
	environ['PATH_INFO'] = '/login'

	fields = self.server_response.items()
	content_type, body = encode_multipart_formdata(fields)
	environ['wsgi.input'] = StringIO(body)
	environ['REQUEST_METHOD'] = 'POST'
	environ['CONTENT_LENGTH'] = len(body)
	environ['CONTENT_TYPE'] = content_type
	
	identity = self.plugin.identify(environ)
	self.assertEqual(identity['repoze.who.plugins.openid.userid'],'http://repoze.myopenid.com')
コード例 #3
0
    def test_login_form_send(self):
        """test if the login form data is received and the environment set correctly"""
        fields = [('repoze.whoplugins.openid.openid', 'foobar.com')]
        content_type, body = encode_multipart_formdata(fields)

        environ = self.environ
        environ['wsgi.input'] = StringIO(body)
        environ['REQUEST_METHOD'] = 'POST'
        environ['CONTENT_LENGTH'] = len(body)
        environ['CONTENT_TYPE'] = content_type
        environ['PATH_INFO'] = '/login'

        identity = self.plugin.identify(environ)
        self.assertEqual(environ.get('repoze.whoplugins.openid.openid', None),
                         'foobar.com')
コード例 #4
0
    def test_complete_openid_request(self):
        """test if the openid request completes"""

        environ = self.environ
        environ['PATH_INFO'] = '/login'

        fields = self.server_response.items()
        content_type, body = encode_multipart_formdata(fields)
        environ['wsgi.input'] = StringIO(body)
        environ['REQUEST_METHOD'] = 'POST'
        environ['CONTENT_LENGTH'] = len(body)
        environ['CONTENT_TYPE'] = content_type

        identity = self.plugin.identify(environ)
        self.assertEqual(identity['repoze.who.plugins.openid.userid'],
                         'http://repoze.myopenid.com')
コード例 #5
0
ファイル: test_challenge.py プロジェクト: mbellotti/hdx-ckan
    def test_challenge_redirect(self):
	"""check if the challenge plugin works if given an openid"""

	# create a form POST response as if we would post the openid
	fields = [('repoze.whoplugins.openid.openid','foobar.com')]
	content_type, body = encode_multipart_formdata(fields)

	environ = self.environ
	environ['wsgi.input'] = StringIO(body)
	environ['REQUEST_METHOD'] = 'POST'
	environ['CONTENT_LENGTH'] = len(body)
	environ['CONTENT_TYPE'] = content_type

	# in this case the plugin has to redirect to the openid provider
	# faked by MockConsumer in this case
	res = self.plugin.challenge(environ, '200 Ok', {}, {})
	self.assertEqual(res.location,'http://someopenidprovider.com/somewhere')
	self.assertEqual(res.status,'302 Found')
コード例 #6
0
ファイル: test_challenge.py プロジェクト: mbellotti/hdx-ckan
    def test_incomplete_openid_request(self):
	"""test if the openid request fails with a wrong identity"""

	environ = self.environ
	environ['PATH_INFO'] = '/login'

	sresp = self.server_response
	sresp['openid.identity'] = ''

	fields = sresp.items()
	content_type, body = encode_multipart_formdata(fields)
	environ['wsgi.input'] = StringIO(body)
	environ['REQUEST_METHOD'] = 'POST'
	environ['CONTENT_LENGTH'] = len(body)
	environ['CONTENT_TYPE'] = content_type
	
	identity = self.plugin.identify(environ)
	self.assertEqual(identity.get('repoze.who.plugins.openid.userid',None),None)
コード例 #7
0
    def test_challenge_redirect(self):
        """check if the challenge plugin works if given an openid"""

        # create a form POST response as if we would post the openid
        fields = [('repoze.whoplugins.openid.openid', 'foobar.com')]
        content_type, body = encode_multipart_formdata(fields)

        environ = self.environ
        environ['wsgi.input'] = StringIO(body)
        environ['REQUEST_METHOD'] = 'POST'
        environ['CONTENT_LENGTH'] = len(body)
        environ['CONTENT_TYPE'] = content_type

        # in this case the plugin has to redirect to the openid provider
        # faked by MockConsumer in this case
        res = self.plugin.challenge(environ, '200 Ok', {}, {})
        self.assertEqual(res.location,
                         'http://someopenidprovider.com/somewhere')
        self.assertEqual(res.status, '302 Found')
コード例 #8
0
    def test_incomplete_openid_request(self):
        """test if the openid request fails with a wrong identity"""

        environ = self.environ
        environ['PATH_INFO'] = '/login'

        sresp = self.server_response
        sresp['openid.identity'] = ''

        fields = sresp.items()
        content_type, body = encode_multipart_formdata(fields)
        environ['wsgi.input'] = StringIO(body)
        environ['REQUEST_METHOD'] = 'POST'
        environ['CONTENT_LENGTH'] = len(body)
        environ['CONTENT_TYPE'] = content_type

        identity = self.plugin.identify(environ)
        self.assertEqual(
            identity.get('repoze.who.plugins.openid.userid', None), None)