Пример #1
0
    def test_negative_auth_post_saml_invalid_saml(self):
        """
        Check exception raised while posting saml with invalid saml, and verify the exception contains correct error messages.
        """
        # get auth first
        head, content = utils.auth_get_auth()
        # get cookie
        cookie = head['set-cookie']
        logging.info("The retrieved cookie from Auth server is '%s'" % str(cookie))
        header = utils.headers
        header['cookie'] = cookie
        logging.debug("The requested headers are '%s'" % str(header))

        http = httplib2.Http()
        # construct invalid responses
        invalid_saml = [utils.random_str()]
        for isa in invalid_saml:
            logging.info("The invalid saml to be tested is '%s'" % str(isa))
            url = 'http://' + utils.auth_server + '/' + utils.auth_partner + '/saml'
            logging.info("The requested url is '%s'" % url)
            saml = {'SAMLResponse': isa}
            h, c = http.request(url, 'POST', headers = header, body = urlencode(saml))
            # assert response head status is 400
            self.assertEqual(int(h['status']), 400)
            # assert error msg is correct
            utils.verify_rest_requetfailed_exception(c, utils.get_exception("InvalidSAML", "AuthPostSamlGrantExceptions"), self)
Пример #2
0
 def test_positive_auth_post_saml_check_return(self):
     """
     Check the response contains correct return.
     """
     # get auth first
     head, content = utils.auth_get_auth()
     # get cookie
     cookie = head['set-cookie']
     logging.info("The retrieved cookie from Auth server is '%s'" % str(cookie))
     header = utils.headers
     header['cookie'] = cookie
     logging.debug("The requested headers are '%s'" % str(header))
     # post saml
     http = httplib2.Http()
     url = 'http://' + utils.auth_server + '/' + utils.auth_partner + '/saml'
     logging.debug("The requested url is '%s'" % str(url))
     h, c = http.request(url, 'POST', headers = header, body = utils.auth_body)
     # verification for redirection to resource server e.g. mozypro? check
     logging.info("The retrieved response head is '%s'" % str(h))
     logging.info("The retrieved response content is '%s'" % str(c))
     # assert it's a redirection exception
     self.assertTrue(int(h['status']), 302)
     # assert location is returned
     self.assertTrue(h.has_key('location'))
     # assert location content is correct 
     self.assertTrue(h['location'].find('access_token') != -1, "The access_token isn't returned!")
     self.assertTrue(h['location'].find('token_type=bearer') != -1, "The token_type isn't bearer!")
Пример #3
0
 def test_postive_auth_get_auth_horizon_check_return(self):
     """
     Check the response contains correct return.
     """
     # get auth
     head, content = utils.auth_get_auth()
     # assert status code is 302 
     self.assertEqual(int(head['status']), 302)
     # assert head has set-cookie keyword
     self.assertTrue(head.has_key('set-cookie'))
     # assert cookie content is correct
     self.assertTrue(head['set-cookie'].find('mozy.auth.horizon') != -1, "The cookie 'mozy.auth.horizon' was not found in reponse head!")
     # assert location is returned
     self.assertTrue(head.has_key('location'))