8000 fix(api): compute permission on application (#3938) · ovh/cds@dc9290a · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit dc9290a

Browse files
bnjjjfsamin
authored andcommitted
fix(api): compute permission on application (#3938)
Signed-off-by: Benjamin Coenen <benjamin.coenen@corp.ovh.com>
1 parent d5f6ff3 commit dc9290a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

engine/api/application.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ func (api *API) getApplicationsHandler() service.Handler {
6161
return sdk.WrapError(err, "Cannot load applications from db")
6262
}
6363

64+
projectPerm := permission.ProjectPermission(projectKey, u)
65+
for i := range applications {
66+
applications[i].Permission = projectPerm
67+
}
68+
6469
if strings.ToUpper(withPermissions) == "W" {
6570
res := make([]sdk.Application, 0, len(applications))
6671
for _, a := range applications {

engine/api/application_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@ func Test_postApplicationMetadataHandler_AsProvider(t *testing.T) {
5151
assert.Equal(t, "a1", app.Metadata["a1"])
5252
assert.Equal(t, "b1", app.Metadata["b1"])
5353

54+
apps, err := sdkclient.ApplicationsList(pkey, cdsclient.FilterByUser(u.Username), cdsclient.FilterByWritablePermission())
55+
test.NoError(t, err)
56+
assert.Equal(t, 1, len(apps))
5457
}

0 commit comments

Comments
 (0)
0