Esempio n. 1
0
 def test_generate_valid_webfinger(self):
     webfinger = generate_legacy_webfinger("diaspora",
                                           handle="*****@*****.**",
                                           host="https://server.example",
                                           guid="0123456789abcdef",
                                           public_key="ABCDEF==")
     assert webfinger.decode("UTF-8") == DIASPORA_WEBFINGER
 def test_generate_valid_webfinger(self):
     webfinger = generate_legacy_webfinger(
         "diaspora",
         handle="*****@*****.**",
         host="https://server.example",
         guid="0123456789abcdef",
         public_key="ABCDEF=="
     )
     assert webfinger.decode("UTF-8") == DIASPORA_WEBFINGER
Esempio n. 3
0
def webfinger():
    account = request.args.get("q", "")
    if account != app.config.get("RELAY_ACCOUNT"):
        return abort(404)
    webfinger = generate_legacy_webfinger(
        "diaspora",
        handle=app.config.get("RELAY_ACCOUNT"),
        host=app.config.get("SERVER_HOST"),
        guid=app.config.get("RELAY_GUID"),
        public_key=app.config.get("RELAY_PUBLIC_KEY")
    )
    return Response(webfinger, status=200, mimetype="application/xrd+xml")
Esempio n. 4
0
def webfinger():
    account = request.args.get("q", "")
    if account.startswith("acct:"):
        account = account.replace("acct:", "", 1)
    if account != app.config.get("RELAY_ACCOUNT"):
        return abort(404)
    webfinger = generate_legacy_webfinger(
        "diaspora",
        handle=app.config.get("RELAY_ACCOUNT"),
        host=app.config.get("SERVER_HOST"),
        guid=app.config.get("RELAY_GUID"),
        public_key=app.config.get("RELAY_PUBLIC_KEY"))
    return Response(webfinger, status=200, mimetype="application/xrd+xml")
Esempio n. 5
0
def webfinger_view(request):
    """Generate a webfinger document."""
    q = request.GET.get("q")
    if not q:
        raise Http404()
    username = q.split("@")[0]
    if username.startswith("acct:"):
        username = username.replace("acct:", "", 1)
    user = get_object_or_404(User, username=username)
    # Create webfinger document
    webfinger = generate_legacy_webfinger(
        "diaspora",
        handle="{username}@{domain}".format(username=user.username,
                                            domain=settings.SOCIALHOME_DOMAIN),
        host=settings.SOCIALHOME_URL,
        guid=str(user.profile.guid),
        public_key=user.profile.rsa_public_key)
    return HttpResponse(webfinger, content_type="application/xrd+xml")
Esempio n. 6
0
 def test_diaspora_webfinger_raises_on_missing_arguments(self):
     with pytest.raises(TypeError):
         generate_legacy_webfinger("diaspora")
 def test_diaspora_webfinger_raises_on_missing_arguments(self):
     with pytest.raises(TypeError):
         generate_legacy_webfinger("diaspora")