Skip to content

Commit

Permalink
[Misc] Add $XSAPPNAMECallback & $XSAPPNAME.mtcallback scope to xs-sec…
Browse files Browse the repository at this point in the history
…urity.json (#21)
  • Loading branch information
anirudhprasad-sap authored Jul 19, 2024
1 parent 060cb4e commit 91a5519
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
18 changes: 18 additions & 0 deletions files/xs-security.json.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"scopes": [
{
"name": "$XSAPPNAME.Callback",
"description": "Subscription via SaaS Registry for CAP Operator",
"grant-as-authority-to-apps": [
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
]
},
{
"name": "$XSAPPNAME.mtcallback",
"description": "Subscription via SaaS Registry",
"grant-as-authority-to-apps": [
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
]
}
]
}
6 changes: 6 additions & 0 deletions lib/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ module.exports = class CapOperatorAddPlugin extends cds.add.Plugin {
if (hasXsuaa) {
const xsuaaaYaml = yaml.parse(Mustache.render( await read(join(__dirname, '../files/xsuaa.yaml.hbs')), project))
await cds.add.merge(xsuaaaYaml).into(valuesYaml)

await cds.add.merge(__dirname, '../files/xs-security.json.hbs').into('xs-security.json', {
project,
additions: [{ in: 'scopes', where: { name: '$XSAPPNAME.Callback' }},
{ in: 'scopes', where: { name: '$XSAPPNAME.mtcallback' }}]
})
}

if (hasApprouter || exists('approuter')) {
Expand Down
3 changes: 3 additions & 0 deletions test/add.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ describe('cds add cap-operator', () => {
expect(getFileHash(join(__dirname,'files/expectedChart/Chart.yaml'))).to.equal(getFileHash(join(bookshop, 'chart/Chart.yaml')))
expect(getFileHash(join(__dirname,'files/expectedChart/values.schema.json'))).to.equal(getFileHash(join(bookshop, 'chart/values.schema.json')))
expect(getFileHash(join(__dirname,'files/expectedChart/values.yaml'))).to.equal(getFileHash(join(bookshop, 'chart/values.yaml')))

// Check changes to xs-security.json
expect(getFileHash(join(__dirname,'files/xs-security.json'))).to.equal(getFileHash(join(bookshop, 'xs-security.json')))
})

it('Add cap-operator chart with force', async () => {
Expand Down
21 changes: 21 additions & 0 deletions test/files/xs-security.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"scopes": [
{
"name": "$XSAPPNAME.mtcallback",
"description": "Subscription via SaaS Registry",
"grant-as-authority-to-apps": [
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
]
},
{
"name": "$XSAPPNAME.Callback",
"description": "Subscription via SaaS Registry for CAP Operator",
"grant-as-authority-to-apps": [
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
]
}
],
"attributes": [],
"role-templates": [],
"authorities-inheritance": false
}

0 comments on commit 91a5519

Please sign in to comment.