FIX: Allow plugins to correctly extend API key scopes. (#12113)

Adding a scope from a plugin was broken. This commit fixes it and adds a test.

It also documents the instance method and renames the serialized "id" attribute to "scope_id" to avoid a conflict when the scope also has a parameter with the same name.
This commit is contained in:
Roman Rizzi
2021-02-17 14:42:44 -03:00
committed by GitHub
parent a174c8b8d4
commit 07cf0f9460
5 changed files with 31 additions and 10 deletions

View File

@ -137,7 +137,7 @@ describe Admin::ApiController do
post "/admin/api/keys.json", params: {
key: {
description: "master key description",
scopes: [{ id: 'topics:write', topic_id: '55' }]
scopes: [{ scope_id: 'topics:write', topic_id: '55' }]
}
}
expect(response.status).to eq(200)
@ -154,7 +154,7 @@ describe Admin::ApiController do
post "/admin/api/keys.json", params: {
key: {
description: "master key description",
scopes: [{ id: 'topics:write', topic_id: '55,33' }]
scopes: [{ scope_id: 'topics:write', topic_id: '55,33' }]
}
}
expect(response.status).to eq(200)
@ -170,7 +170,7 @@ describe Admin::ApiController do
post "/admin/api/keys.json", params: {
key: {
description: "master key description",
scopes: [{ id: 'topics:write', fake_id: '55' }]
scopes: [{ scope_id: 'topics:write', fake_id: '55' }]
}
}
@ -186,7 +186,7 @@ describe Admin::ApiController do
post "/admin/api/keys.json", params: {
key: {
description: "master key description",
scopes: [{ id: 'something:else' }]
scopes: [{ scope_id: 'something:else' }]
}
}