Files
shadowdaoandClaude Sonnet 5.5 962d708fdd Rename Go module paths to repo.anhonesthost.net/CyberCoveLLC/threshold
Rename root, api and sdk module paths (imports, go.mod, go_package,
ldflags, build scripts, buf configs) and regenerate protobuf/gateway
code with the project's pinned toolchain. Wire identifiers unchanged.
api gets a local replace for sdk; root/api/sdk require v0.1.0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 10:33:41 -07:00

117 lines
2.9 KiB
Go

// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: BUSL-1.1
package groups_test
import (
"context"
"encoding/json"
"testing"
"time"
"repo.anhonesthost.net/CyberCoveLLC/threshold/sdk/pbs/controller/api"
pb "repo.anhonesthost.net/CyberCoveLLC/threshold/sdk/pbs/controller/api/resources/groups"
"repo.anhonesthost.net/CyberCoveLLC/threshold/sdk/pbs/controller/api/resources/scopes"
"repo.anhonesthost.net/CyberCoveLLC/threshold/sdk/wrapper"
"github.com/hashicorp/eventlogger"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
)
func TestGroupsClassification(t *testing.T) {
ctx := context.Background()
now := time.Now()
pbNow := timestamppb.Now()
wrapper := wrapper.TestWrapper(t)
testEncryptingFilter := api.NewEncryptFilter(t, wrapper)
cases := []struct {
name string
in *eventlogger.Event
want *eventlogger.Event
}{
{
name: "validate-group-filtering",
in: &eventlogger.Event{
Type: "test",
CreatedAt: now,
Payload: &pb.Group{
Id: "id",
ScopeId: "scope-id",
Scope: &scopes.ScopeInfo{
Id: "id",
Type: "type",
Name: "name",
Description: "description",
ParentScopeId: "parent-scope-id",
},
Name: &wrapperspb.StringValue{Value: "name"},
Description: &wrapperspb.StringValue{Value: "description"},
CreatedTime: pbNow,
UpdatedTime: pbNow,
Version: 1,
MemberIds: []string{"member-id"},
Members: []*pb.Member{
{
Id: "member-id",
ScopeId: "scope-id",
},
},
AuthorizedActions: []string{
"action-1",
"action-2",
},
},
},
want: &eventlogger.Event{
Type: "test",
CreatedAt: now,
Payload: &pb.Group{
Id: "id",
ScopeId: "scope-id",
Scope: &scopes.ScopeInfo{
Id: "id",
Type: "type",
Name: "name",
Description: "description",
ParentScopeId: "parent-scope-id",
},
Name: &wrapperspb.StringValue{Value: "name"},
Description: &wrapperspb.StringValue{Value: "description"},
CreatedTime: pbNow,
UpdatedTime: pbNow,
Version: 1,
MemberIds: []string{"member-id"},
Members: []*pb.Member{
{
Id: "member-id",
ScopeId: "scope-id",
},
},
AuthorizedActions: []string{
"action-1",
"action-2",
},
},
},
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
assert, require := assert.New(t), require.New(t)
got, err := testEncryptingFilter.Process(ctx, tc.in)
require.NoError(err)
require.NotNil(got)
gotJSON, err := json.Marshal(got)
require.NoError(err)
wantJSON, err := json.Marshal(tc.want)
require.NoError(err)
assert.JSONEq(string(wantJSON), string(gotJSON))
})
}
}