diff options
author | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2023-05-17 18:51:26 +0000 |
---|---|---|
committer | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2023-05-17 18:51:26 +0000 |
commit | ce1c0f75cdde09243ed0f6983d3dff3458386f24 (patch) | |
tree | a45182d2648f0395903b543c881bc594e0a38572 /test | |
parent | 66327b56e946f58f4ffe724f8329bad929acb875 (diff) | |
parent | 9283c784a38194a937dc1a46a6b46478d159e434 (diff) | |
download | pleroma-ce1c0f75cdde09243ed0f6983d3dff3458386f24.tar.gz pleroma-ce1c0f75cdde09243ed0f6983d3dff3458386f24.zip |
Merge branch 'tusooa/3065-scopes' into 'develop'
OAuth scopes descriptions
Closes #3065
See merge request pleroma/pleroma!3848
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/api_spec/scopes/compiler_test.exs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/pleroma/web/api_spec/scopes/compiler_test.exs b/test/pleroma/web/api_spec/scopes/compiler_test.exs new file mode 100644 index 000000000..99e1d343a --- /dev/null +++ b/test/pleroma/web/api_spec/scopes/compiler_test.exs @@ -0,0 +1,56 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.ApiSpec.Scopes.CompilerTest do + use ExUnit.Case, async: true + + alias Pleroma.Web.ApiSpec.Scopes.Compiler + + @dummy_response %{} + + @data %{ + paths: %{ + "/mew" => %OpenApiSpex.PathItem{ + post: %OpenApiSpex.Operation{ + security: [%{"oAuth" => ["a:b:c"]}], + responses: @dummy_response + }, + get: %OpenApiSpex.Operation{security: nil, responses: @dummy_response} + }, + "/mew2" => %OpenApiSpex.PathItem{ + post: %OpenApiSpex.Operation{ + security: [%{"oAuth" => ["d:e", "f:g"]}], + responses: @dummy_response + }, + get: %OpenApiSpex.Operation{security: nil, responses: @dummy_response} + } + } + } + + describe "process_scope/1" do + test "gives all higher-level scopes" do + scopes = Compiler.process_scope("admin:read:accounts") + + assert [_, _, _] = scopes + assert "admin" in scopes + assert "admin:read" in scopes + assert "admin:read:accounts" in scopes + end + end + + describe "extract_all_scopes_from/1" do + test "extracts scopes" do + scopes = Compiler.extract_all_scopes_from(@data) + + assert [_, _, _, _, _, _, _] = scopes + assert "a" in scopes + assert "a:b" in scopes + assert "a:b:c" in scopes + assert "d" in scopes + assert "d:e" in scopes + assert "f" in scopes + assert "f:g" in scopes + end + end +end |