Skip to content

Commit

Permalink
Chore: Fix for failing Bruno tests (#121)
Browse files Browse the repository at this point in the history
Co-authored-by: Jon Kjetil Øye <[email protected]>
  • Loading branch information
jonkjetiloye and Jon Kjetil Øye authored Dec 6, 2024
1 parent e714b58 commit 0408c23
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
meta {
name: AppWithDelegableRights_Ok
name: InstDelg_DelgChk_AppWithDelegableRights_Ok
type: http
seq: 1
}
Expand Down Expand Up @@ -43,9 +43,11 @@ script:pre-request {
}

tests {
test("AppsInstanceDelegation DelegationCheck GET AppWithDelegableRights_Ok", function() {
var body = res.getBody();
var data = body.data;
// Should be the same as the .bru request file. Used as prefix in test name which also shows in test result in pipeline.
const requestName = "InstDelg_DelgChk_AppWithDelegableRights_Ok";
const data = res.getBody().data;

test(requestName, function() {
expect(res.status).to.equal(200);
expect(data[0]).to.have.property('rightKey', 'app_ttd_authz-bruno-instancedelegation,task_1:read')
expect(data[0]).to.have.property('status', 'Delegable')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
meta {
name: AppWithoutDelegableRights_BadRequest
name: InstDelg_DelgChk_AppWithoutDelegableRights_OkEmpty
type: http
seq: 2
}
Expand Down Expand Up @@ -43,10 +43,12 @@ script:pre-request {
}

tests {
test("AppsInstanceDelegation DelegationCheck GET AppWithoutDelegableRights_Forbidden", function() {
var body = res.getBody();
expect(res.status).to.equal(400);
expect(body.validationErrors[0].code).to.equal("AM.VLD-00004");
expect(body.validationErrors[0].paths[0]).to.equal("appInstanceDelegationRequest.Resource");
// Should be the same as the .bru request file. Used as prefix in test name which also shows in test result in pipeline.
const requestName = "InstDelg_DelgChk_AppWithoutDelegableRights_OkEmpty";
const body = res.getBody();

test(requestName + "|HttpStatus.OK and Body.Data empty", function() {
expect(res.status).to.equal(200);
assert.isEmpty(body.data, `Expected data in body to be empty.`);
});
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
meta {
name: MissingToken_NotAuthorized
name: InstDelg_DelgChk_MissingToken_NotAuthorized
type: http
seq: 4
}
Expand All @@ -18,7 +18,7 @@ params:path {
headers {
Accept: application/json
PlatformAccessToken: {{platformAccessToken}}
Ocp-Apim-Subscription-Key: {{apimSubscriptionKey}}
~Ocp-Apim-Subscription-Key: {{apimSubscriptionKey}}
}

script:pre-request {
Expand All @@ -30,8 +30,12 @@ script:pre-request {
}

tests {
test("AppsInstanceDelegation DelegationCheck GET MissingToken_NotAuthorized", function() {
var body = res.getBody();
// Should be the same as the .bru request file. Used as prefix in test name which also shows in test result in pipeline.
const requestName = "InstDelg_DelgChk_MissingToken_NotAuthorized";
const body = res.getBody();

test(requestName, function() {
expect(res.status).to.equal(401);
assert.isNotOk(body, `Expected body to be empty. Actual: ${JSON.stringify(body)}`);
});
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
meta {
name: PlatformAccessToken_BadRequest
name: InstDelg_DelgChk_PlatformAccessToken_OkEmpty
type: http
seq: 3
}
Expand Down Expand Up @@ -43,10 +43,12 @@ script:pre-request {
}

tests {
test("AppsInstanceDelegation DelegationCheck GET PlatformAccessToken_Forbidden", function() {
var body = res.getBody();
expect(res.status).to.equal(400);
expect(body.validationErrors[0].code).to.equal("AM.VLD-00004");
expect(body.validationErrors[0].paths[0]).to.equal("appInstanceDelegationRequest.Resource");
// Should be the same as the .bru request file. Used as prefix in test name which also shows in test result in pipeline.
const requestName = "InstDelg_DelgChk_PlatformAccessToken_OkEmpty";
const body = res.getBody();

test(requestName + "|HttpStatus.OK and Body.Data empty", function() {
expect(res.status).to.equal(200);
assert.isEmpty(body.data, `Expected data in body to be empty.`);
});
}

0 comments on commit 0408c23

Please sign in to comment.