diff --git a/api/source/service/mysql/CollectionService.js b/api/source/service/mysql/CollectionService.js index 85e00ada3..dabc2c8ca 100644 --- a/api/source/service/mysql/CollectionService.js +++ b/api/source/service/mysql/CollectionService.js @@ -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 @@ -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') diff --git a/api/source/specification/stig-manager.yaml b/api/source/specification/stig-manager.yaml index 57029bb18..773006f48 100644 --- a/api/source/specification/stig-manager.yaml +++ b/api/source/specification/stig-manager.yaml @@ -2787,7 +2787,7 @@ components: owners: type: array items: - $ref: '#/components/schemas/UserBasic' + $ref: '#/components/schemas/User' statistics: type: object CollectionStatus: @@ -3378,6 +3378,10 @@ components: readOnly: true username: type: string + displayName: + type: string + email: + type: string UserBasic: type: object properties: diff --git a/test/api/postman_collection.json b/test/api/postman_collection.json index 5de853a7c..b6100c328 100644 --- a/test/api/postman_collection.json +++ b/test/api/postman_collection.json @@ -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", @@ -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", @@ -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\",", @@ -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", @@ -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",