Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes nuwcdivnpt/stig-manager#103 #369

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions api/source/service/mysql/CollectionService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
const writer = require('../../utils/writer.js')
const dbUtils = require('./utils')
const config = require('../../utils/config.js')

const _this = this

Expand Down Expand Up @@ -90,15 +91,19 @@ exports.queryCollections = async function (inProjection = [], inPredicates = {},
(select json_arrayagg(
json_object(
'userId', CAST(user_data.userId as char),
'username', user_data.username
'username', user_data.username,
'email', JSON_VALUE(user_data.lastClaims, "$.${config.oauth.claims.email}"),
'displayName', JSON_VALUE(user_data.lastClaims, "$.${config.oauth.claims.name}")
)
)
from collection_grant left join user_data using (userId)
from collection_grant
left join user_data using (userId)
where collectionId = c.collectionId and accessLevel = 4)
, json_array()
)
) as "owners"`)
}

if (inProjection.includes('statistics')) {
if (context == dbUtils.CONTEXT_USER) {
joins.push('left join collection_grant cgstat on c.collectionId = cgstat.collectionId')
Expand Down
6 changes: 5 additions & 1 deletion api/source/specification/stig-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2787,7 +2787,7 @@ components:
owners:
type: array
items:
$ref: '#/components/schemas/UserBasic'
$ref: '#/components/schemas/User'
statistics:
type: object
CollectionStatus:
Expand Down Expand Up @@ -3378,6 +3378,10 @@ components:
readOnly: true
username:
type: string
displayName:
type: string
email:
type: string
UserBasic:
type: object
properties:
Expand Down
40 changes: 22 additions & 18 deletions test/api/postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -1758,13 +1758,15 @@
"\r",
"// START AZDO #151\r",
"let userBasicKeys = [\r",
" // \"user\",\r",
" // \"accessLevel\",\r",
" \"userId\",\r",
" \"username\"\r",
" // ,\r",
" // \"display\",\r",
" // \"email\" \r",
"]\r",
"\r",
"let userKeys = [\r",
" \"userId\",\r",
" \"username\",\r",
" \"displayName\",\r",
" \"email\" \r",
"]\r",
"// END AZDO #151\r",
"\r",
Expand Down Expand Up @@ -1851,7 +1853,7 @@
" if (pm.request.url.getQueryString().match(/projection=owners/)) {\r",
" // console.log(\"checking owners projection\");\r",
" for (let owner of jsonData.owners){\r",
" pm.expect(owner).to.have.all.keys(userBasicKeys);\r",
" pm.expect(owner).to.have.all.keys(userKeys);\r",
" }\r",
" }\r",
"\r",
Expand Down Expand Up @@ -2338,13 +2340,13 @@
" \"lastRevisionStr\"",
"]",
"",
"let ownerKeys = [",
" \"userId\",",
" \"username\"",
" // ,",
" // \"display\",",
" // \"email\"",
"]",
"let ownerKeys = [\r",
" \"userId\",\r",
" \"username\",\r",
" \"displayName\",\r",
" \"email\" \r",
"]\r",

"",
"let statisticsKeys = [",
" \"created\",",
Expand Down Expand Up @@ -8161,10 +8163,12 @@
"let userBasicKeys = [\r",
" \"userId\",\r",
" \"username\"\r",
" // \"userId\",\r",
" // \"username\",\r",
" // \"display\",\r",
" // \"email\" \r",
"]\r",
"let userKeys = [\r",
" \"userId\",\r",
" \"username\",\r",
" \"displayName\",\r",
" \"email\" \r",
"]\r",
"// END AZDO #151\r",
"\r",
Expand Down Expand Up @@ -8243,7 +8247,7 @@
" if (pm.request.url.getQueryString().match(/projection=owners/)) {\r",
" // console.log(\"checking owners projection\");\r",
" for (let owner of jsonData.owners){\r",
" pm.expect(owner).to.have.all.keys(userBasicKeys);\r",
" pm.expect(owner).to.have.all.keys(userKeys);\r",
" }\r",
" }\r",
"\r",
Expand Down