本文整理汇总了Python中tests.base.fake.md5函数的典型用法代码示例。如果您正苦于以下问题:Python md5函数的具体用法?Python md5怎么用?Python md5使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了md5函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_make_response_from_ticket_invalidates_verification_key
def test_make_response_from_ticket_invalidates_verification_key(self, mock_service_validate):
self.user.verification_key = fake.md5()
self.user.save()
mock_response = make_successful_response(self.user)
mock_service_validate.return_value = mock_response
ticket = fake.md5()
service_url = 'http://accounts.osf.io/?ticket=' + ticket
resp = cas.make_response_from_ticket(ticket, service_url)
示例2: test_make_response_from_ticket_invalidates_verification_key
def test_make_response_from_ticket_invalidates_verification_key(self, mock_service_validate):
self.user.verification_key = fake.md5()
self.user.save()
mock_service_validate.return_value = make_successful_response(self.user)
ticket = fake.md5()
service_url = 'http://localhost:5000/'
resp = cas.make_response_from_ticket(ticket, service_url)
assert_true(self.user.verification_key is None)
示例3: test_make_response_from_ticket_invalidates_verification_key
def test_make_response_from_ticket_invalidates_verification_key(self, mock_service_validate):
self.user.verification_key = fake.md5()
self.user.save()
mock_response = make_external_response()
validated_creds = cas.validate_external_credential(mock_response.user)
self.user.external_identity = {validated_creds["provider"]: {validated_creds["id"]: "VERIFIED"}}
self.user.save()
mock_service_validate.return_value = mock_response
ticket = fake.md5()
service_url = "http://accounts.osf.io/?ticket=" + ticket
resp = cas.make_response_from_ticket(ticket, service_url)
示例4: make_successful_response
def make_successful_response(user):
return cas.CasResponse(
authenticated=True, user=user._primary_key,
attributes={
'accessToken': fake.md5()
}
)
示例5: test_make_response_from_ticket_failure
def test_make_response_from_ticket_failure(self, mock_service_validate):
mock_response = make_failure_response()
mock_service_validate.return_value = mock_response
ticket = fake.md5()
service_url = 'http://accounts.osf.io/?ticket=' + ticket
resp = cas.make_response_from_ticket(ticket, service_url)
assert_equal(resp.status_code, 302)
assert_equal(resp.location, 'http://accounts.osf.io/')
示例6: test_make_response_from_ticket_generates_new_verification_key
def test_make_response_from_ticket_generates_new_verification_key(self, mock_service_validate):
self.user.verification_key = fake.md5()
self.user.save()
mock_response = make_external_response()
validated_creds = cas.validate_external_credential(mock_response.user)
self.user.external_identity = {
validated_creds['provider']: {
validated_creds['id']: 'VERIFIED'
}
}
self.user.save()
mock_service_validate.return_value = mock_response
ticket = fake.md5()
service_url = 'http://localhost:5000/'
verification_key = self.user.verification_key
resp = cas.make_response_from_ticket(ticket, service_url)
assert_not_equal(self.user.verification_key, verification_key)
示例7: test_make_response_from_ticket_no_user
def test_make_response_from_ticket_no_user(self, mock_service_validate):
mock_response = make_external_response()
mock_service_validate.return_value = mock_response
ticket = fake.md5()
service_url = "http://accounts.osf.io/?ticket=" + ticket
resp = cas.make_response_from_ticket(ticket, service_url)
assert_equal(resp.status_code, 302)
assert_equal(resp.location, "/external-login/email")
示例8: test_successful_external_first_login_without_attributes
def test_successful_external_first_login_without_attributes(self, mock_service_validate, mock_get_user_from_cas_resp, mock_external_first_login_authenticate):
service_url = 'http://localhost:5000/dashboard/'
user, validated_credentials, cas_resp = generate_external_user_with_resp(service_url, user=False, release=False)
mock_service_validate.return_value = cas_resp
mock_get_user_from_cas_resp.return_value = (None, validated_credentials, 'external_first_login')
ticket = fake.md5()
cas.make_response_from_ticket(ticket, service_url)
assert_equal(user, mock_external_first_login_authenticate.call_args[0][0])
示例9: test_parse_authorization_header
def test_parse_authorization_header():
token = fake.md5()
valid = 'Bearer {}'.format(token)
assert_equal(cas.parse_auth_header(valid), token)
missing_token = 'Bearer '
with assert_raises(cas.CasTokenError):
cas.parse_auth_header(missing_token)
示例10: test_make_response_from_ticket_success
def test_make_response_from_ticket_success(self, mock_service_validate, mock_get_user_from_cas_resp):
mock_service_validate.return_value = make_successful_response(self.user)
mock_get_user_from_cas_resp.return_value = (self.user, None, 'authenticate')
ticket = fake.md5()
service_url = 'http://localhost:5000/'
resp = cas.make_response_from_ticket(ticket, service_url)
assert_equal(resp.status_code, 302)
assert_equal(mock_service_validate.call_count, 1)
assert_equal(mock_get_user_from_cas_resp.call_count, 1)
示例11: make_service_validation_response_body
def make_service_validation_response_body(user, access_token=None):
token = access_token or fake.md5()
return RESPONSE_TEMPLATE.format(
user_id=user._primary_key,
given_name=user.given_name,
family_name=user.family_name,
username=user.username,
access_token=token
)
示例12: test_make_response_from_ticket_failure
def test_make_response_from_ticket_failure(self, mock_service_validate, mock_get_user_from_cas_resp):
mock_service_validate.return_value = make_failure_response()
mock_get_user_from_cas_resp.return_value = (None, None, None)
ticket = fake.md5()
service_url = 'http://localhost:5000/'
resp = cas.make_response_from_ticket(ticket, service_url)
assert_equal(resp.status_code, 302)
assert_equal(mock_service_validate.call_count, 1)
assert_equal(mock_get_user_from_cas_resp.call_count, 0)
示例13: test_successful_external_first_login
def test_successful_external_first_login(self, mock_service_validate, mock_get_user_from_cas_resp):
service_url = 'http://localhost:5000/dashboard/'
_, validated_credentials, cas_resp = generate_external_user_with_resp(service_url, user=False)
mock_service_validate.return_value = cas_resp
mock_get_user_from_cas_resp.return_value = (None, validated_credentials, 'external_first_login')
ticket = fake.md5()
resp = cas.make_response_from_ticket(ticket, service_url)
assert_equal(resp.status_code, 302, 'redirect to external login email get')
assert_in('/external-login/email', resp.location)
示例14: make_external_response
def make_external_response():
return cas.CasResponse(
authenticated=True,
user='OrcidProfile#{}'.format(fake.numerify('####-####-####-####')),
attributes={
'given-names': fake.first_name(),
'family-name': fake.last_name(),
'accessToken': fake.md5(),
}
)
示例15: test_service_validate
def test_service_validate(self):
user = UserFactory()
url = furl.furl(self.base_url)
url.path.segments.extend(("p3", "serviceValidate"))
service_url = "http://test.osf.io"
ticket = fake.md5()
body = make_service_validation_response_body(user, ticket)
httpretty.register_uri(httpretty.GET, url.url, body=body, status=200)
resp = self.client.service_validate(ticket, service_url)
assert_true(resp.authenticated)