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

feat: new appinfo implementation #1403

Merged
merged 2 commits into from
Oct 10, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/api-audit-test-coverage-response.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ env:
STIGMAN_SWAGGER_SERVER: http://localhost:64001/api
STIGMAN_SWAGGER_REDIRECT: http://localhost:64001/api-docs/oauth2-redirect.html
STIGMAN_DEV_RESPONSE_VALIDATION: logOnly
STIGMAN_EXPERIMENTAL_APPDATA: 'true'
NODE_V8_COVERAGE: /home/runner/work/stig-manager/stig-manager/api/source/coverage/tmp/

permissions:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/api-container-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
-e STIGMAN_DB_PASSWORD=stigman \
-e STIGMAN_API_AUTHORITY=http://127.0.0.1:8080/auth/realms/stigman \
-e STIGMAN_DEV_RESPONSE_VALIDATION=logOnly \
-e STIGMAN_EXPERIMENTAL_APPDATA=true \
${{ matrix.container.name }}

- name: Install test dependencies
Expand Down
12 changes: 10 additions & 2 deletions api/source/controllers/Operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ module.exports.setConfigurationItem = async function setConfigurationItem (req,

module.exports.getAppData = async function getAppData (req, res, next) {
try {
if (!config.experimental.appData) {
throw new SmError.NotFoundError('endpoint disabled, to enable set STIGMAN_EXPERIMENTAL_APPDATA=true')
}
let elevate = req.query.elevate
if ( elevate ) {
let collections = await Collection.exportCollections( ['grants', 'labels', 'stigs'], elevate, req.userObject )
Expand Down Expand Up @@ -81,6 +84,9 @@ module.exports.getAppData = async function getAppData (req, res, next) {

module.exports.replaceAppData = async function replaceAppData (req, res, next) {
try {
if (!config.experimental.appData) {
throw new SmError.NotFoundError('endpoint disabled, to enable set STIGMAN_EXPERIMENTAL_APPDATA=true')
}
req.noCompression = true
let elevate = req.query.elevate
let appdata
Expand Down Expand Up @@ -129,11 +135,11 @@ module.exports.getDefinition = async function getDefinition (req, res, next) {
}
}

module.exports.getDetails = async function getDetails (req, res, next) {
module.exports.getAppInfo = async function getAppInfo (req, res, next) {
try {
let elevate = req.query.elevate
if ( elevate ) {
const response = await OperationService.getDetails()
const response = await OperationService.getAppInfo()
res.json(response)
}
else {
Expand All @@ -144,3 +150,5 @@ module.exports.getDetails = async function getDetails (req, res, next) {
next(err)
}
}

module.exports.getDetails = module.exports.getAppInfo
5 changes: 4 additions & 1 deletion api/source/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ app.use((err, req, res, next) => {
})
}
// Expose selected error properties in the response
res.errorBody = { error: err.message, detail: err.detail, stack: err.stack}
res.errorBody = { error: err.message, code: err.code, detail: err.detail, stack: err.stack}
if (!res._headerSent) {
res.status(err.status || 500).header(err.headers).json(res.errorBody)
}
Expand Down Expand Up @@ -224,6 +224,9 @@ const STIGMAN = {
privileges: "${config.oauth.claims.privileges}",
email: "${config.oauth.claims.email}"
}
},
experimental: {
appData: "${config.experimental.appData}"
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions api/source/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading