Skip to content

Commit

Permalink
fix(core): sm list should provide value fqn instead of just value str…
Browse files Browse the repository at this point in the history
…ing (#438)

required a change in the platform to expose the value's FQN on SM list:
opentdf/platform#1796
  • Loading branch information
jakedoublev authored Dec 3, 2024
1 parent bed3701 commit 9a7cb72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
15 changes: 4 additions & 11 deletions cmd/policy-subjectMappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,11 @@ func policy_listSubjectMappings(cmd *cobra.Command, args []string) {
}
t := cli.NewTable(
cli.NewUUIDColumn(),
table.NewFlexColumn("subject_attrval_id", "Subject AttrVal: Id", cli.FlexColumnWidthFour),
table.NewFlexColumn("subject_attrval_value", "Subject AttrVal: Value", cli.FlexColumnWidthThree),
table.NewFlexColumn("value_id", "Attribute Value Id", cli.FlexColumnWidthFour),
table.NewFlexColumn("value_fqn", "Attibribute Value FQN", cli.FlexColumnWidthFour),
table.NewFlexColumn("actions", "Actions", cli.FlexColumnWidthTwo),
table.NewFlexColumn("subject_condition_set_id", "Subject Condition Set: Id", cli.FlexColumnWidthFour),
table.NewFlexColumn("subject_condition_set", "Subject Condition Set", cli.FlexColumnWidthThree),
table.NewFlexColumn("labels", "Labels", cli.FlexColumnWidthOne),
table.NewFlexColumn("created_at", "Created At", cli.FlexColumnWidthOne),
table.NewFlexColumn("updated_at", "Updated At", cli.FlexColumnWidthOne),
)
rows := []table.Row{}
for _, sm := range list {
Expand All @@ -90,18 +87,14 @@ func policy_listSubjectMappings(cmd *cobra.Command, args []string) {
if subjectSetsJSON, err = json.Marshal(sm.GetSubjectConditionSet().GetSubjectSets()); err != nil {
cli.ExitWithError("Error marshalling subject condition set", err)
}
metadata := cli.ConstructMetadata(sm.GetMetadata())

rows = append(rows, table.NewRow(table.RowData{
"id": sm.GetId(),
"subject_attrval_id": sm.GetAttributeValue().GetId(),
"subject_attrval_value": sm.GetAttributeValue().GetValue(),
"value_id": sm.GetAttributeValue().GetId(),
"value_fqn": sm.GetAttributeValue().GetFqn(),
"actions": string(actionsJSON),
"subject_condition_set_id": sm.GetSubjectConditionSet().GetId(),
"subject_condition_set": string(subjectSetsJSON),
"labels": metadata["Labels"],
"created_at": metadata["Created At"],
"updated_at": metadata["Updated At"],
}))
}
t = t.WithRows(rows)
Expand Down
3 changes: 3 additions & 0 deletions e2e/subject-mapping.bats
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ teardown_file() {
run_otdfctl_sm list
assert_success
assert_output --partial "$created"

run_otdfctl_sm list --json
[ "$(echo $output | jq -r ".[] | select(.id == \"$created\") | .attribute_value.fqn")" == "https://subject-mappings.net/attr/attr1/value/val1" ]
}

@test "Delete subject mapping" {
Expand Down

0 comments on commit 9a7cb72

Please sign in to comment.