コード例 #1
0
ファイル: views.py プロジェクト: mozilla/django-salmon
def endpoint(request):
    parsed = utils.parse_magic_envelope(request.raw_post_data)
    parsed['data'] = utils.decode(parsed['data'])

    # verify that data was signed by sender
    author_uri = utils.parse_author_uri_from_atom(parsed['data'])
    if not magicsigs.verify(author_uri, parsed['data'], parsed['sig']):
        return HttpResponseBadRequest("Could not verify magic signature.")

    # verify that the timestamp is recent
    updated = utils.parse_updated_from_atom(parsed['data'])
    if not utils.verify_timestamp(updated):
        return HttpResponseBadRequest("Invalid timestamp.")

    # hand waving on mime_type right now, but seems like this'd be
    # a decent interface.
    utils.slap_notify(parsed['data'], 'application/atom+xml')

    return HttpResponse('slapped: %s' % (parsed,))
コード例 #2
0
def test_almost_old_timestamp():
    updated = utils.parse_updated_from_atom(almost_old_entry)
    assert utils.verify_timestamp(updated)
コード例 #3
0
def test_new_timestamp():
    updated = utils.parse_updated_from_atom(newer_atom_entry)
    assert utils.verify_timestamp(updated)