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
4 changes: 4 additions & 0 deletions protocol/go/authorization/v2/resource.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions protocol/go/internal/authorization/v2/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
// ForAttributeValues returns a Resource containing the given attribute value FQNs.
// This is the most common Resource variant, used when authorizing against
// attribute values attached to data (e.g. those on a TDF).
// At least one FQN is required; calling with zero arguments panics.
func ForAttributeValues(fqns ...string) *authorizationv2.Resource {
if len(fqns) == 0 {
panic("ForAttributeValues requires at least one FQN")
}
return &authorizationv2.Resource{
Resource: &authorizationv2.Resource_AttributeValues_{
AttributeValues: &authorizationv2.Resource_AttributeValues{
Expand Down
18 changes: 7 additions & 11 deletions protocol/go/internal/authorization/v2/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,13 @@ func TestForAttributeValues_Single(t *testing.T) {
}
}

func TestForAttributeValues_ZeroArgs(t *testing.T) {
r := ForAttributeValues()

av, ok := r.GetResource().(*authorizationv2proto.Resource_AttributeValues_)
if !ok {
t.Fatal("expected AttributeValues resource")
}
got := av.AttributeValues.GetFqns()
if len(got) != 0 {
t.Fatalf("fqns len = %d, want 0", len(got))
}
func TestForAttributeValues_ZeroArgs_Panics(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Fatal("expected panic for zero FQNs, but did not panic")
}
}()
ForAttributeValues()
}

func TestForRegisteredResourceValueFqn(t *testing.T) {
Expand Down
Loading