Skip to content

Commit c0a9dda

Browse files
authored
fix(policy): return fqns in list subject mappings (#1796)
### Proposed Changes * returns mapped attribute value FQNs in `ListSubjectMappings` as FQNs provide the namespace and definition of the attribute value ### Checklist - [ ] I have added or updated unit tests - [ ] I have added or updated integration tests (if appropriate) - [ ] I have added or updated documentation ### Testing Instructions
1 parent 7ae172f commit c0a9dda

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

service/integration/subject_mappings_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,17 @@ func (s *SubjectMappingsSuite) Test_ListSubjectMappings_NoPagination_Succeeds()
404404
for _, sm := range listed {
405405
if sm.GetId() == fixture1.ID {
406406
assertEqual(sm, fixture1)
407+
s.Equal("https://example.com/attr/attr1/value/value1", sm.GetAttributeValue().GetFqn())
407408
found1 = true
408409
}
409410
if sm.GetId() == fixture2.ID {
410411
assertEqual(sm, fixture2)
412+
s.Equal("https://example.com/attr/attr1/value/value2", sm.GetAttributeValue().GetFqn())
411413
found2 = true
412414
}
413415
if sm.GetId() == fixture3.ID {
414416
assertEqual(sm, fixture3)
417+
s.Equal("https://example.com/attr/attr1/value/value1", sm.GetAttributeValue().GetFqn())
415418
found3 = true
416419
}
417420
}

service/policy/db/query.sql

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,13 +839,19 @@ SELECT
839839
'metadata', JSON_STRIP_NULLS(JSON_BUILD_OBJECT('labels', scs.metadata->'labels', 'created_at', scs.created_at, 'updated_at', scs.updated_at)),
840840
'subject_sets', scs.condition
841841
) AS subject_condition_set,
842-
JSON_BUILD_OBJECT('id', av.id,'value', av.value,'active', av.active) AS attribute_value,
842+
JSON_BUILD_OBJECT(
843+
'id', av.id,
844+
'value', av.value,
845+
'active', av.active,
846+
'fqn', fqns.fqn
847+
) AS attribute_value,
843848
counted.total
844849
FROM subject_mappings sm
845850
CROSS JOIN counted
846851
LEFT JOIN attribute_values av ON sm.attribute_value_id = av.id
852+
LEFT JOIN attribute_fqns fqns ON av.id = fqns.value_id
847853
LEFT JOIN subject_condition_set scs ON scs.id = sm.subject_condition_set_id
848-
GROUP BY av.id, sm.id, scs.id, counted.total
854+
GROUP BY av.id, sm.id, scs.id, counted.total, fqns.fqn
849855
LIMIT @limit_
850856
OFFSET @offset_;
851857

service/policy/db/query.sql.go

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)