Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,11 @@ private void ProcessResourceAllowAccessReasons(List<RightPermission> resourceRig
/// <inheritdoc />
public async Task<Result<bool>> AddResource(Entity from, Entity to, Resource resourceObj, RightKeyListDto rightKeys, Entity by, Action<ConnectionOptions> configureConnection = null, CancellationToken cancellationToken = default)
{
if (!rightKeys.DirectRightKeys.Any())
{
return Problems.MissingRightKey;
}

var canDelegate = await ResourceDelegationCheck(by.Id, from.Id, resourceObj?.RefId, ConfigureConnections, cancellationToken: cancellationToken);
if (canDelegate.IsProblem)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
meta {
name: Post_Enduser_Conn_Resources_Dagl_NoRights
type: http
seq: 2
}

post {
url: {{baseUrl}}/accessmanagement/api/v1/enduser/connections/resources/rights?party={{party}}&from={{from}}&to={{to}}&resource={{resource}}
body: json
auth: inherit
}

params:query {
party: {{party}}
from: {{from}}
to: {{to}}
resource: {{resource}}
}

headers {
Accept: application/json
}

body:json {
{
"DirectRightKeys": []
}
}

script:pre-request {
const sharedtestdata = require(`./testdata/sharedtestdata.js`);
const testdata = require(`./testdata/resource-delegationcheck/${bru.getEnvVar("tokenEnv")}.js`);

bru.setVar("requestName", "GET_Enduser_Conn_Resources_DelgCheck_Dagl");

bru.setVar("party", testdata.VOKSENDE_FRYKTLØS_TIGER.partyUuid);
bru.setVar("from", testdata.VOKSENDE_FRYKTLØS_TIGER.partyUuid);
bru.setVar("to", testdata.KOMPLEKS_LOJAL_TIGER.dagligleder.partyUuid);
bru.setVar("resource", testdata.resources.packageResourceId);

var getTokenParameters = {
auth_userId: testdata.VOKSENDE_FRYKTLØS_TIGER.dagligleder.userId,
auth_partyId: testdata.VOKSENDE_FRYKTLØS_TIGER.dagligleder.partyId,
auth_partyUuid: testdata.VOKSENDE_FRYKTLØS_TIGER.dagligleder.partyUuid,
auth_ssn: testdata.VOKSENDE_FRYKTLØS_TIGER.dagligleder.pid,
auth_tokenType: sharedtestdata.authTokenType.personal,
auth_scopes: sharedtestdata.auth_scopes.enduserSystemToOthersWrite
}


const testTokenGenerator = require(`./TestToolsTokenGenerator.js`);
const token = await testTokenGenerator.getToken(getTokenParameters);
bru.setVar("bearerToken", token);
}

tests {

test(bru.getVar("requestName"), function() {
const body = res.getBody();
const actions = body.actions;

expect(res.status).to.equal(400);
expect(body.code).to.equal("AM-00031")
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,8 @@ private static readonly ProblemDescriptorFactory _factory
/// <summary>Gets a <see cref="ProblemDescriptor"/>.</summary>
public static ProblemDescriptor AssignmentNotFound { get; }
= _factory.Create(30, HttpStatusCode.InternalServerError, "The assignment was not found");

/// <summary>Gets a <see cref="ProblemDescriptor"/>.</summary>
public static ProblemDescriptor MissingRightKey { get; }
= _factory.Create(31, HttpStatusCode.BadRequest, "No right key provided");
}
Loading