Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Routes
module Resources
class List < AbstractAuthenticatedRoute
include ForestAdminDatasourceToolkit::Components::Query::ConditionTree
include ForestAdminDatasourceToolkit::Validations

def setup_routes
add_route('forest_list', 'get', '/:collection_name', ->(args) { handle_request(args) })
Expand All @@ -30,6 +31,8 @@ def handle_request(args = {})
segment: ForestAdminAgent::Utils::QueryStringParser.parse_segment(@collection, args)
)

ConditionTreeValidator.validate(filter.condition_tree, @collection) if filter.condition_tree

projection = ForestAdminAgent::Utils::QueryStringParser.parse_projection_with_pks(@collection, args)
records = @collection.list(@caller, filter, projection)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def get_current_user_data(context_variable_key)
end

if context_variable_key.start_with?(USER_VALUE_TAG_PREFIX)
tag_key = context_variable_key[USER_VALUE_TAG_PREFIX.length..]
user[:tags].each do |tag|
match_key = context_variable_key[USER_VALUE_TAG_PREFIX.length..]
return tag[match_key] if tag.key?(match_key)
return tag['value'] if tag['key'] == tag_key
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ module Capabilities
let(:args) do
{
headers: { 'HTTP_AUTHORIZATION' => bearer },
params: { 'timezone' => 'Europe/Paris' }
params: {
'collectionNames' => [],
'timezone' => 'Europe/Paris'
}
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Utils
'lastName' => 'Doe',
'fullName' => 'John Doe',
'email' => 'john.doe@domain.com',
'tags' => [{ 'planet' => 'Death Star' }],
'tags' => [{ 'key' => 'planet', 'value' => 'Death Star' }],
'roleId' => 1,
'permissionLevel' => 'admin'
}
Expand Down Expand Up @@ -89,7 +89,7 @@ module Utils
{ key: 'id', expected_value: user['id'] },
{ key: 'permissionLevel', expected_value: user['permissionLevel'] },
{ key: 'roleId', expected_value: user['roleId'] },
{ key: 'tags.planet', expected_value: user['tags'][0]['planet'] },
{ key: 'tags.planet', expected_value: user['tags'][0]['value'] },
{ key: 'team.id', expected_value: team['id'] },
{ key: 'team.name', expected_value: team['name'] }
].each do |value|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Utils
lastName: 'Doe',
fullName: 'John Doe',
email: 'johndoe@forestadmin.com',
tags: [{ 'foo' => 'bar' }],
tags: [{ 'key' => 'foo', 'value' => 'bar' }],
roleId: 1,
permissionLevel: 'admin'
}
Expand Down