mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
VAULT-15396: Client count testing library (#20774)
* fluent generation of client count testing data input * godocs * add VerifyInput and complete testing * pr fixes * pr fixes * buf lint
This commit is contained in:
8
buf.yaml
8
buf.yaml
@@ -5,11 +5,11 @@ version: v1
|
||||
lint:
|
||||
ignore_only:
|
||||
ENUM_VALUE_PREFIX:
|
||||
- vault/activity/generation/generate_data.proto
|
||||
- sdk/helper/clientcountutil/generation/generate_data.proto
|
||||
- vault/hcp_link/proto/node_status/status.proto
|
||||
- vault/replication_services_ent.proto
|
||||
ENUM_ZERO_VALUE_SUFFIX:
|
||||
- vault/activity/generation/generate_data.proto
|
||||
- sdk/helper/clientcountutil/generation/generate_data.proto
|
||||
- vault/hcp_link/proto/node_status/status.proto
|
||||
- vault/replication_services_ent.proto
|
||||
FIELD_LOWER_SNAKE_CASE:
|
||||
@@ -42,7 +42,7 @@ lint:
|
||||
- sdk/logical/version.proto
|
||||
- sdk/plugin/pb/backend.proto
|
||||
- vault/activity/activity_log.proto
|
||||
- vault/activity/generation/generate_data.proto
|
||||
- sdk/helper/clientcountutil/generation/generate_data.proto
|
||||
- vault/hcp_link/proto/link_control/link_control.proto
|
||||
- vault/hcp_link/proto/meta/meta.proto
|
||||
- vault/hcp_link/proto/node_status/status.proto
|
||||
@@ -72,7 +72,7 @@ lint:
|
||||
- sdk/logical/version.proto
|
||||
- sdk/plugin/pb/backend.proto
|
||||
- vault/activity/activity_log.proto
|
||||
- vault/activity/generation/generate_data.proto
|
||||
- sdk/helper/clientcountutil/generation/generate_data.proto
|
||||
- vault/hcp_link/proto/link_control/link_control.proto
|
||||
- vault/hcp_link/proto/meta/meta.proto
|
||||
- vault/hcp_link/proto/node_status/status.proto
|
||||
|
||||
398
sdk/helper/clientcountutil/clientcountutil.go
Normal file
398
sdk/helper/clientcountutil/clientcountutil.go
Normal file
@@ -0,0 +1,398 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
// Package clientcountutil provides a library to generate activity log data for
|
||||
// testing.
|
||||
package clientcountutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/sdk/helper/clientcountutil/generation"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
// ActivityLogDataGenerator holds an ActivityLogMockInput. Users can create the
|
||||
// generator with NewActivityLogData(), add content to the generator using
|
||||
// the fluent API methods, and generate and write the JSON representation of the
|
||||
// input to the Vault API.
|
||||
type ActivityLogDataGenerator struct {
|
||||
data *generation.ActivityLogMockInput
|
||||
addingToMonth *generation.Data
|
||||
addingToSegment *generation.Segment
|
||||
client *api.Client
|
||||
}
|
||||
|
||||
// NewActivityLogData creates a new instance of an activity log data generator
|
||||
// The type returned by this function cannot be called concurrently
|
||||
func NewActivityLogData(client *api.Client) *ActivityLogDataGenerator {
|
||||
return &ActivityLogDataGenerator{
|
||||
client: client,
|
||||
data: new(generation.ActivityLogMockInput),
|
||||
}
|
||||
}
|
||||
|
||||
// NewCurrentMonthData opens a new month of data for the current month. All
|
||||
// clients will continue to be added to this month until a new month is created
|
||||
// with NewPreviousMonthData.
|
||||
func (d *ActivityLogDataGenerator) NewCurrentMonthData() *ActivityLogDataGenerator {
|
||||
return d.newMonth(&generation.Data{Month: &generation.Data_CurrentMonth{CurrentMonth: true}})
|
||||
}
|
||||
|
||||
// NewPreviousMonthData opens a new month of data, where the clients will be
|
||||
// recorded as having been seen monthsAgo months ago. All clients will continue
|
||||
// to be added to this month until a new month is created with
|
||||
// NewPreviousMonthData or NewCurrentMonthData.
|
||||
func (d *ActivityLogDataGenerator) NewPreviousMonthData(monthsAgo int) *ActivityLogDataGenerator {
|
||||
return d.newMonth(&generation.Data{Month: &generation.Data_MonthsAgo{MonthsAgo: int32(monthsAgo)}})
|
||||
}
|
||||
|
||||
func (d *ActivityLogDataGenerator) newMonth(newMonth *generation.Data) *ActivityLogDataGenerator {
|
||||
d.data.Data = append(d.data.Data, newMonth)
|
||||
d.addingToMonth = newMonth
|
||||
d.addingToSegment = nil
|
||||
return d
|
||||
}
|
||||
|
||||
// MonthOption holds an option that can be set for the entire month
|
||||
type MonthOption func(m *generation.Data)
|
||||
|
||||
// WithMaximumSegmentIndex sets the maximum segment index for the segments in
|
||||
// the open month. Set this value in order to set how many indexes the data
|
||||
// should be split across. This must include any empty or skipped indexes. For
|
||||
// example, say that you would like all of your data split across indexes 0 and
|
||||
// 3, with the following empty and skipped indexes:
|
||||
//
|
||||
// empty indexes: [2]
|
||||
// skipped indexes: [1]
|
||||
//
|
||||
// To accomplish that, you will need to call WithMaximumSegmentIndex(3).
|
||||
// This value will be ignored if you have called Segment() for the open month
|
||||
// If not set, all data will be in 1 segment.
|
||||
func WithMaximumSegmentIndex(n int) MonthOption {
|
||||
return func(m *generation.Data) {
|
||||
m.NumSegments = int32(n)
|
||||
}
|
||||
}
|
||||
|
||||
// WithEmptySegmentIndexes sets which segment indexes should be empty for the
|
||||
// segments in the open month. If you use this option, you must either:
|
||||
// 1. ensure that you've called Segment() for the open month
|
||||
// 2. use WithMaximumSegmentIndex() to set the total number of segments
|
||||
//
|
||||
// If you haven't set either of those values then this option will be ignored,
|
||||
// unless you included 0 as an empty segment index in which case only an empty
|
||||
// segment will be created.
|
||||
func WithEmptySegmentIndexes(i ...int) MonthOption {
|
||||
return func(m *generation.Data) {
|
||||
indexes := make([]int32, 0, len(i))
|
||||
for _, index := range i {
|
||||
indexes = append(indexes, int32(index))
|
||||
}
|
||||
m.EmptySegmentIndexes = indexes
|
||||
}
|
||||
}
|
||||
|
||||
// WithSkipSegmentIndexes sets which segment indexes should be skipped for the
|
||||
// segments in the open month. If you use this option, you must either:
|
||||
// 1. ensure that you've called Segment() for the open month
|
||||
// 2. use WithMaximumSegmentIndex() to set the total number of segments
|
||||
//
|
||||
// If you haven't set either of those values then this option will be ignored,
|
||||
// unless you included 0 as a skipped segment index in which case no segments
|
||||
// will be created.
|
||||
func WithSkipSegmentIndexes(i ...int) MonthOption {
|
||||
return func(m *generation.Data) {
|
||||
indexes := make([]int32, 0, len(i))
|
||||
for _, index := range i {
|
||||
indexes = append(indexes, int32(index))
|
||||
}
|
||||
m.SkipSegmentIndexes = indexes
|
||||
}
|
||||
}
|
||||
|
||||
// SetMonthOptions can be called at any time to set options for the open month
|
||||
func (d *ActivityLogDataGenerator) SetMonthOptions(opts ...MonthOption) *ActivityLogDataGenerator {
|
||||
for _, opt := range opts {
|
||||
opt(d.addingToMonth)
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
// ClientOption defines additional options for the client
|
||||
// This type and the functions that return it are here for ease of use. A user
|
||||
// could also choose to create the *generation.Client themselves, without using
|
||||
// a ClientOption
|
||||
type ClientOption func(client *generation.Client)
|
||||
|
||||
// WithClientNamespace sets the namespace for the client
|
||||
func WithClientNamespace(n string) ClientOption {
|
||||
return func(client *generation.Client) {
|
||||
client.Namespace = n
|
||||
}
|
||||
}
|
||||
|
||||
// WithClientMount sets the mount path for the client
|
||||
func WithClientMount(m string) ClientOption {
|
||||
return func(client *generation.Client) {
|
||||
client.Mount = m
|
||||
}
|
||||
}
|
||||
|
||||
// WithClientIsNonEntity sets whether the client is an entity client or a non-
|
||||
// entity token client
|
||||
func WithClientIsNonEntity() ClientOption {
|
||||
return func(client *generation.Client) {
|
||||
client.NonEntity = true
|
||||
}
|
||||
}
|
||||
|
||||
// WithClientID sets the ID for the client
|
||||
func WithClientID(id string) ClientOption {
|
||||
return func(client *generation.Client) {
|
||||
client.Id = id
|
||||
}
|
||||
}
|
||||
|
||||
// ClientsSeen adds clients to the month that was most recently opened with
|
||||
// NewPreviousMonthData or NewCurrentMonthData.
|
||||
func (d *ActivityLogDataGenerator) ClientsSeen(clients ...*generation.Client) *ActivityLogDataGenerator {
|
||||
if d.addingToSegment == nil {
|
||||
if d.addingToMonth.Clients == nil {
|
||||
d.addingToMonth.Clients = &generation.Data_All{All: &generation.Clients{}}
|
||||
}
|
||||
d.addingToMonth.GetAll().Clients = append(d.addingToMonth.GetAll().Clients, clients...)
|
||||
return d
|
||||
}
|
||||
d.addingToSegment.Clients.Clients = append(d.addingToSegment.Clients.Clients, clients...)
|
||||
return d
|
||||
}
|
||||
|
||||
// NewClientSeen adds 1 new client with the given options to the most recently
|
||||
// opened month.
|
||||
func (d *ActivityLogDataGenerator) NewClientSeen(opts ...ClientOption) *ActivityLogDataGenerator {
|
||||
return d.NewClientsSeen(1, opts...)
|
||||
}
|
||||
|
||||
// NewClientsSeen adds n new clients with the given options to the most recently
|
||||
// opened month.
|
||||
func (d *ActivityLogDataGenerator) NewClientsSeen(n int, opts ...ClientOption) *ActivityLogDataGenerator {
|
||||
c := new(generation.Client)
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
c.Count = int32(n)
|
||||
return d.ClientsSeen(c)
|
||||
}
|
||||
|
||||
// RepeatedClientSeen adds 1 client that was seen in the previous month to
|
||||
// the month that was most recently opened. This client will have the attributes
|
||||
// described by the provided options.
|
||||
func (d *ActivityLogDataGenerator) RepeatedClientSeen(opts ...ClientOption) *ActivityLogDataGenerator {
|
||||
return d.RepeatedClientsSeen(1, opts...)
|
||||
}
|
||||
|
||||
// RepeatedClientsSeen adds n clients that were seen in the previous month to
|
||||
// the month that was most recently opened. These clients will have the
|
||||
// attributes described by provided options.
|
||||
func (d *ActivityLogDataGenerator) RepeatedClientsSeen(n int, opts ...ClientOption) *ActivityLogDataGenerator {
|
||||
c := new(generation.Client)
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
c.Repeated = true
|
||||
c.Count = int32(n)
|
||||
return d.ClientsSeen(c)
|
||||
}
|
||||
|
||||
// RepeatedClientSeenFromMonthsAgo adds 1 client that was seen in monthsAgo
|
||||
// month to the month that was most recently opened. This client will have the
|
||||
// attributes described by provided options.
|
||||
func (d *ActivityLogDataGenerator) RepeatedClientSeenFromMonthsAgo(monthsAgo int, opts ...ClientOption) *ActivityLogDataGenerator {
|
||||
return d.RepeatedClientsSeenFromMonthsAgo(1, monthsAgo, opts...)
|
||||
}
|
||||
|
||||
// RepeatedClientsSeenFromMonthsAgo adds n clients that were seen in monthsAgo
|
||||
// month to the month that was most recently opened. These clients will have the
|
||||
// attributes described by provided options.
|
||||
func (d *ActivityLogDataGenerator) RepeatedClientsSeenFromMonthsAgo(n, monthsAgo int, opts ...ClientOption) *ActivityLogDataGenerator {
|
||||
c := new(generation.Client)
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
c.RepeatedFromMonth = int32(monthsAgo)
|
||||
c.Count = int32(n)
|
||||
return d.ClientsSeen(c)
|
||||
}
|
||||
|
||||
// SegmentOption defines additional options for the segment
|
||||
type SegmentOption func(segment *generation.Segment)
|
||||
|
||||
// WithSegmentIndex sets the index for the segment to n. If this option is not
|
||||
// provided, the segment will be given the next consecutive index
|
||||
func WithSegmentIndex(n int) SegmentOption {
|
||||
return func(segment *generation.Segment) {
|
||||
index := int32(n)
|
||||
segment.SegmentIndex = &index
|
||||
}
|
||||
}
|
||||
|
||||
// Segment starts a segment within the current month. All clients will be added
|
||||
// to this segment, until either Segment is called again to create a new open
|
||||
// segment, or NewPreviousMonthData or NewCurrentMonthData is called to open a
|
||||
// new month.
|
||||
func (d *ActivityLogDataGenerator) Segment(opts ...SegmentOption) *ActivityLogDataGenerator {
|
||||
s := &generation.Segment{
|
||||
Clients: &generation.Clients{},
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(s)
|
||||
}
|
||||
if d.addingToMonth.GetSegments() == nil {
|
||||
d.addingToMonth.Clients = &generation.Data_Segments{Segments: &generation.Segments{}}
|
||||
}
|
||||
d.addingToMonth.GetSegments().Segments = append(d.addingToMonth.GetSegments().Segments, s)
|
||||
d.addingToSegment = s
|
||||
return d
|
||||
}
|
||||
|
||||
// ToJSON returns the JSON representation of the data
|
||||
func (d *ActivityLogDataGenerator) ToJSON() ([]byte, error) {
|
||||
return protojson.Marshal(d.data)
|
||||
}
|
||||
|
||||
// ToProto returns the ActivityLogMockInput protobuf
|
||||
func (d *ActivityLogDataGenerator) ToProto() *generation.ActivityLogMockInput {
|
||||
return d.data
|
||||
}
|
||||
|
||||
// Write writes the data to the API with the given write options. The method
|
||||
// returns the new paths that have been written. Note that the API endpoint will
|
||||
// only be present when Vault has been compiled with the "testonly" flag.
|
||||
func (d *ActivityLogDataGenerator) Write(ctx context.Context, writeOptions ...generation.WriteOptions) ([]string, error) {
|
||||
d.data.Write = writeOptions
|
||||
err := VerifyInput(d.data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data, err := d.ToJSON()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := d.client.Logical().WriteBytesWithContext(ctx, "sys/internal/counters/activity/write", data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if resp.Data == nil {
|
||||
return nil, fmt.Errorf("received no data")
|
||||
}
|
||||
paths := resp.Data["paths"]
|
||||
castedPaths, ok := paths.([]interface{})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid paths data: %v", paths)
|
||||
}
|
||||
returnPaths := make([]string, 0, len(castedPaths))
|
||||
for _, path := range castedPaths {
|
||||
returnPaths = append(returnPaths, path.(string))
|
||||
}
|
||||
return returnPaths, nil
|
||||
}
|
||||
|
||||
// VerifyInput checks that the input data is valid
|
||||
func VerifyInput(input *generation.ActivityLogMockInput) error {
|
||||
// mapping from monthsAgo to the month's data
|
||||
months := make(map[int32]*generation.Data)
|
||||
|
||||
// this keeps track of the index of the earliest month. We need to verify
|
||||
// that this month doesn't have any repeated clients
|
||||
earliestMonthsAgo := int32(0)
|
||||
|
||||
// this map holds a set of the month indexes for any RepeatedFromMonth
|
||||
// values. Each element will be checked to ensure month that should be
|
||||
// repeated from exists in the input data
|
||||
repeatedFromMonths := make(map[int32]struct{})
|
||||
|
||||
for _, month := range input.Data {
|
||||
monthsAgo := month.GetMonthsAgo()
|
||||
if monthsAgo > earliestMonthsAgo {
|
||||
earliestMonthsAgo = monthsAgo
|
||||
}
|
||||
|
||||
// verify that no monthsAgo value is repeated
|
||||
if _, seen := months[monthsAgo]; seen {
|
||||
return fmt.Errorf("multiple months with monthsAgo %d", monthsAgo)
|
||||
}
|
||||
months[monthsAgo] = month
|
||||
|
||||
// the number of segments should be correct
|
||||
if month.NumSegments > 0 && int(month.NumSegments)-len(month.GetSkipSegmentIndexes())-len(month.GetEmptySegmentIndexes()) <= 0 {
|
||||
return fmt.Errorf("number of segments %d is too small. It must be large enough to include the empty (%v) and skipped (%v) segments", month.NumSegments, month.GetSkipSegmentIndexes(), month.GetEmptySegmentIndexes())
|
||||
}
|
||||
|
||||
if segments := month.GetSegments(); segments != nil {
|
||||
if month.NumSegments > 0 {
|
||||
return errors.New("cannot specify both number of segments and create segmented data")
|
||||
}
|
||||
|
||||
segmentIndexes := make(map[int32]struct{})
|
||||
for _, segment := range segments.Segments {
|
||||
|
||||
// collect any RepeatedFromMonth values
|
||||
for _, client := range segment.GetClients().GetClients() {
|
||||
if repeatFrom := client.RepeatedFromMonth; repeatFrom > 0 {
|
||||
repeatedFromMonths[repeatFrom] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// verify that no segment indexes are repeated
|
||||
segmentIndex := segment.SegmentIndex
|
||||
if segmentIndex == nil {
|
||||
continue
|
||||
}
|
||||
if _, seen := segmentIndexes[*segmentIndex]; seen {
|
||||
return fmt.Errorf("cannot have repeated segment index %d", *segmentIndex)
|
||||
}
|
||||
segmentIndexes[*segmentIndex] = struct{}{}
|
||||
}
|
||||
} else {
|
||||
for _, client := range month.GetAll().GetClients() {
|
||||
// collect any RepeatedFromMonth values
|
||||
if repeatFrom := client.RepeatedFromMonth; repeatFrom > 0 {
|
||||
repeatedFromMonths[repeatFrom] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check that the corresponding month exists for all the RepeatedFromMonth
|
||||
// values
|
||||
for repeated := range repeatedFromMonths {
|
||||
if _, ok := months[repeated]; !ok {
|
||||
return fmt.Errorf("cannot repeat from %d months ago", repeated)
|
||||
}
|
||||
}
|
||||
// the earliest month can't have any repeated clients, because there are no
|
||||
// earlier months to repeat from
|
||||
earliestMonth := months[earliestMonthsAgo]
|
||||
repeatedClients := false
|
||||
if all := earliestMonth.GetAll(); all != nil {
|
||||
for _, client := range all.GetClients() {
|
||||
repeatedClients = repeatedClients || client.Repeated || client.RepeatedFromMonth != 0
|
||||
}
|
||||
} else {
|
||||
for _, segment := range earliestMonth.GetSegments().GetSegments() {
|
||||
for _, client := range segment.GetClients().GetClients() {
|
||||
repeatedClients = repeatedClients || client.Repeated || client.RepeatedFromMonth != 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if repeatedClients {
|
||||
return fmt.Errorf("%d months ago cannot have repeated clients, because it is the earliest month", earliestMonthsAgo)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
275
sdk/helper/clientcountutil/clientcountutil_test.go
Normal file
275
sdk/helper/clientcountutil/clientcountutil_test.go
Normal file
@@ -0,0 +1,275 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package clientcountutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/sdk/helper/clientcountutil/generation"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestNewCurrentMonthData verifies that current month is set correctly and that
|
||||
// there are no open segments
|
||||
func TestNewCurrentMonthData(t *testing.T) {
|
||||
generator := NewActivityLogData(nil).NewCurrentMonthData()
|
||||
require.True(t, generator.data.Data[0].GetCurrentMonth())
|
||||
require.True(t, generator.addingToMonth.GetCurrentMonth())
|
||||
require.Nil(t, generator.addingToSegment)
|
||||
}
|
||||
|
||||
// TestNewMonthDataMonthsAgo verifies that months ago is set correctly and that
|
||||
// there are no open segments
|
||||
func TestNewMonthDataMonthsAgo(t *testing.T) {
|
||||
generator := NewActivityLogData(nil).NewPreviousMonthData(3)
|
||||
require.Equal(t, int32(3), generator.data.Data[0].GetMonthsAgo())
|
||||
require.Equal(t, int32(3), generator.addingToMonth.GetMonthsAgo())
|
||||
require.Nil(t, generator.addingToSegment)
|
||||
}
|
||||
|
||||
// TestNewMonthData_MultipleMonths opens a month 3 months ago then 2 months ago.
|
||||
// The test verifies that the generator is set to add to the correct month. We
|
||||
// then open a current month, and verify that the generator will add to the
|
||||
// current month.
|
||||
func TestNewMonthData_MultipleMonths(t *testing.T) {
|
||||
generator := NewActivityLogData(nil).NewPreviousMonthData(3).NewPreviousMonthData(2)
|
||||
require.Equal(t, int32(2), generator.data.Data[1].GetMonthsAgo())
|
||||
require.Equal(t, int32(2), generator.addingToMonth.GetMonthsAgo())
|
||||
generator = generator.NewCurrentMonthData()
|
||||
require.True(t, generator.data.Data[2].GetCurrentMonth())
|
||||
require.True(t, generator.addingToMonth.GetCurrentMonth())
|
||||
}
|
||||
|
||||
// TestNewCurrentMonthData_ClientsSeen calls ClientsSeen with 3 clients, and
|
||||
// verifies that they are added to the input data
|
||||
func TestNewCurrentMonthData_ClientsSeen(t *testing.T) {
|
||||
wantClients := []*generation.Client{
|
||||
{
|
||||
Id: "1",
|
||||
Namespace: "ns",
|
||||
Mount: "mount",
|
||||
NonEntity: true,
|
||||
},
|
||||
{
|
||||
Id: "2",
|
||||
},
|
||||
{
|
||||
Id: "3",
|
||||
Count: int32(3),
|
||||
},
|
||||
}
|
||||
generator := NewActivityLogData(nil).NewCurrentMonthData().ClientsSeen(wantClients...)
|
||||
require.Equal(t, generator.data.Data[0].GetAll().Clients, wantClients)
|
||||
require.True(t, generator.data.Data[0].GetCurrentMonth())
|
||||
}
|
||||
|
||||
// TestSegment_AddClients adds clients in a variety of ways to an open segment
|
||||
// and verifies that the clients are present in the segment with the correct
|
||||
// options
|
||||
func TestSegment_AddClients(t *testing.T) {
|
||||
testAddClients(t, func() *ActivityLogDataGenerator {
|
||||
return NewActivityLogData(nil).NewCurrentMonthData().Segment()
|
||||
}, func(g *ActivityLogDataGenerator) *generation.Client {
|
||||
return g.data.Data[0].GetSegments().Segments[0].Clients.Clients[0]
|
||||
})
|
||||
}
|
||||
|
||||
// TestSegment_MultipleSegments opens a current month and adds a client to an
|
||||
// un-indexed segment, then opens an indexed segment and adds a client. The test
|
||||
// verifies that clients are present in both segments, and that the segment
|
||||
// index is correctly recorded
|
||||
func TestSegment_MultipleSegments(t *testing.T) {
|
||||
generator := NewActivityLogData(nil).NewCurrentMonthData().Segment().NewClientSeen().Segment(WithSegmentIndex(2)).NewClientSeen()
|
||||
require.Len(t, generator.data.Data[0].GetSegments().Segments[0].Clients.Clients, 1)
|
||||
require.Len(t, generator.data.Data[0].GetSegments().Segments[1].Clients.Clients, 1)
|
||||
require.Equal(t, int32(2), *generator.data.Data[0].GetSegments().Segments[1].SegmentIndex)
|
||||
require.Equal(t, int32(2), *generator.addingToSegment.SegmentIndex)
|
||||
}
|
||||
|
||||
// TestSegment_NewMonth adds a client to a segment, then starts a new month. The
|
||||
// test verifies that there are no open segments
|
||||
func TestSegment_NewMonth(t *testing.T) {
|
||||
generator := NewActivityLogData(nil).NewCurrentMonthData().Segment().NewClientSeen().NewPreviousMonthData(1)
|
||||
require.Nil(t, generator.addingToSegment)
|
||||
}
|
||||
|
||||
// TestNewCurrentMonthData_AddClients adds clients in a variety of ways to an
|
||||
// the current month and verifies that the clients are present in the month with
|
||||
// the correct options
|
||||
func TestNewCurrentMonthData_AddClients(t *testing.T) {
|
||||
testAddClients(t, func() *ActivityLogDataGenerator {
|
||||
return NewActivityLogData(nil).NewCurrentMonthData()
|
||||
}, func(g *ActivityLogDataGenerator) *generation.Client {
|
||||
return g.data.Data[0].GetAll().Clients[0]
|
||||
})
|
||||
}
|
||||
|
||||
// TestWrite creates a mock http server and writes generated data to it. The
|
||||
// test verifies that the returned paths are parsed correctly, and that the JSON
|
||||
// sent to the server is correct.
|
||||
func TestWrite(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_, err := io.WriteString(w, `{"data":{"paths":["path1","path2"]}}`)
|
||||
require.NoError(t, err)
|
||||
body, err := io.ReadAll(r.Body)
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, `{"write":["WRITE_ENTITIES"],"data":[{"monthsAgo":3,"all":{"clients":[{"count":1}]}},{"monthsAgo":2,"segments":{"segments":[{"segmentIndex":2,"clients":{"clients":[{"count":1,"repeated":true}]}}]}},{"currentMonth":true}]}`, string(body))
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
client, err := api.NewClient(&api.Config{
|
||||
Address: ts.URL,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
paths, err := NewActivityLogData(client).
|
||||
NewPreviousMonthData(3).
|
||||
NewClientSeen().
|
||||
NewPreviousMonthData(2).
|
||||
Segment(WithSegmentIndex(2)).
|
||||
RepeatedClientSeen().
|
||||
NewCurrentMonthData().Write(context.Background(), generation.WriteOptions_WRITE_ENTITIES)
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{"path1", "path2"}, paths)
|
||||
}
|
||||
|
||||
func testAddClients(t *testing.T, makeGenerator func() *ActivityLogDataGenerator, getClient func(data *ActivityLogDataGenerator) *generation.Client) {
|
||||
t.Helper()
|
||||
clientOptions := []ClientOption{
|
||||
WithClientNamespace("ns"), WithClientMount("mount"), WithClientIsNonEntity(), WithClientID("1"),
|
||||
}
|
||||
generator := makeGenerator().NewClientSeen(clientOptions...)
|
||||
require.Equal(t, getClient(generator), &generation.Client{
|
||||
Id: "1",
|
||||
Count: 1,
|
||||
Namespace: "ns",
|
||||
Mount: "mount",
|
||||
NonEntity: true,
|
||||
})
|
||||
|
||||
generator = makeGenerator().NewClientsSeen(4, clientOptions...)
|
||||
require.Equal(t, getClient(generator), &generation.Client{
|
||||
Id: "1",
|
||||
Count: 4,
|
||||
Namespace: "ns",
|
||||
Mount: "mount",
|
||||
NonEntity: true,
|
||||
})
|
||||
|
||||
generator = makeGenerator().RepeatedClientSeen(clientOptions...)
|
||||
require.Equal(t, getClient(generator), &generation.Client{
|
||||
Id: "1",
|
||||
Count: 1,
|
||||
Repeated: true,
|
||||
Namespace: "ns",
|
||||
Mount: "mount",
|
||||
NonEntity: true,
|
||||
})
|
||||
|
||||
generator = makeGenerator().RepeatedClientsSeen(4, clientOptions...)
|
||||
require.Equal(t, getClient(generator), &generation.Client{
|
||||
Id: "1",
|
||||
Count: 4,
|
||||
Repeated: true,
|
||||
Namespace: "ns",
|
||||
Mount: "mount",
|
||||
NonEntity: true,
|
||||
})
|
||||
|
||||
generator = makeGenerator().RepeatedClientSeenFromMonthsAgo(3, clientOptions...)
|
||||
require.Equal(t, getClient(generator), &generation.Client{
|
||||
Id: "1",
|
||||
Count: 1,
|
||||
RepeatedFromMonth: 3,
|
||||
Namespace: "ns",
|
||||
Mount: "mount",
|
||||
NonEntity: true,
|
||||
})
|
||||
|
||||
generator = makeGenerator().RepeatedClientsSeenFromMonthsAgo(4, 3, clientOptions...)
|
||||
require.Equal(t, getClient(generator), &generation.Client{
|
||||
Id: "1",
|
||||
Count: 4,
|
||||
RepeatedFromMonth: 3,
|
||||
Namespace: "ns",
|
||||
Mount: "mount",
|
||||
NonEntity: true,
|
||||
})
|
||||
}
|
||||
|
||||
// TestSetMonthOptions sets month options and verifies that they are saved
|
||||
func TestSetMonthOptions(t *testing.T) {
|
||||
generator := NewActivityLogData(nil).NewCurrentMonthData().SetMonthOptions(WithEmptySegmentIndexes(3, 4),
|
||||
WithMaximumSegmentIndex(7), WithSkipSegmentIndexes(1, 2))
|
||||
require.Equal(t, int32(7), generator.data.Data[0].NumSegments)
|
||||
require.Equal(t, []int32{3, 4}, generator.data.Data[0].EmptySegmentIndexes)
|
||||
require.Equal(t, []int32{1, 2}, generator.data.Data[0].SkipSegmentIndexes)
|
||||
}
|
||||
|
||||
// TestVerifyInput constructs invalid inputs and ensures that VerifyInput
|
||||
// returns an error
|
||||
func TestVerifyInput(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
generator *ActivityLogDataGenerator
|
||||
}{
|
||||
{
|
||||
name: "repeated client with only 1 month",
|
||||
generator: NewActivityLogData(nil).
|
||||
NewCurrentMonthData().
|
||||
RepeatedClientSeen(),
|
||||
},
|
||||
{
|
||||
name: "repeated client with segment",
|
||||
generator: NewActivityLogData(nil).
|
||||
NewCurrentMonthData().
|
||||
Segment().
|
||||
RepeatedClientSeen(),
|
||||
},
|
||||
{
|
||||
name: "repeated client with earliest month",
|
||||
generator: NewActivityLogData(nil).
|
||||
NewCurrentMonthData().
|
||||
NewClientSeen().
|
||||
NewPreviousMonthData(2).
|
||||
RepeatedClientSeen(),
|
||||
},
|
||||
{
|
||||
name: "repeated month",
|
||||
generator: NewActivityLogData(nil).
|
||||
NewPreviousMonthData(1).
|
||||
NewPreviousMonthData(1),
|
||||
},
|
||||
{
|
||||
name: "repeated current month",
|
||||
generator: NewActivityLogData(nil).
|
||||
NewCurrentMonthData().
|
||||
NewCurrentMonthData(),
|
||||
},
|
||||
{
|
||||
name: "repeated segment index",
|
||||
generator: NewActivityLogData(nil).
|
||||
NewCurrentMonthData().
|
||||
Segment(WithSegmentIndex(1)).
|
||||
Segment(WithSegmentIndex(1)),
|
||||
},
|
||||
{
|
||||
name: "segment with num segments",
|
||||
generator: NewActivityLogData(nil).
|
||||
NewCurrentMonthData().
|
||||
Segment().
|
||||
SetMonthOptions(WithMaximumSegmentIndex(1)),
|
||||
},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
require.Error(t, VerifyInput(tc.generator.data))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc (unknown)
|
||||
// source: vault/activity/generation/generate_data.proto
|
||||
// source: sdk/helper/clientcountutil/generation/generate_data.proto
|
||||
|
||||
package generation
|
||||
|
||||
@@ -65,11 +65,11 @@ func (x WriteOptions) String() string {
|
||||
}
|
||||
|
||||
func (WriteOptions) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_vault_activity_generation_generate_data_proto_enumTypes[0].Descriptor()
|
||||
return file_sdk_helper_clientcountutil_generation_generate_data_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (WriteOptions) Type() protoreflect.EnumType {
|
||||
return &file_vault_activity_generation_generate_data_proto_enumTypes[0]
|
||||
return &file_sdk_helper_clientcountutil_generation_generate_data_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x WriteOptions) Number() protoreflect.EnumNumber {
|
||||
@@ -78,7 +78,7 @@ func (x WriteOptions) Number() protoreflect.EnumNumber {
|
||||
|
||||
// Deprecated: Use WriteOptions.Descriptor instead.
|
||||
func (WriteOptions) EnumDescriptor() ([]byte, []int) {
|
||||
return file_vault_activity_generation_generate_data_proto_rawDescGZIP(), []int{0}
|
||||
return file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type ActivityLogMockInput struct {
|
||||
@@ -93,7 +93,7 @@ type ActivityLogMockInput struct {
|
||||
func (x *ActivityLogMockInput) Reset() {
|
||||
*x = ActivityLogMockInput{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_vault_activity_generation_generate_data_proto_msgTypes[0]
|
||||
mi := &file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -106,7 +106,7 @@ func (x *ActivityLogMockInput) String() string {
|
||||
func (*ActivityLogMockInput) ProtoMessage() {}
|
||||
|
||||
func (x *ActivityLogMockInput) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_vault_activity_generation_generate_data_proto_msgTypes[0]
|
||||
mi := &file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -119,7 +119,7 @@ func (x *ActivityLogMockInput) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use ActivityLogMockInput.ProtoReflect.Descriptor instead.
|
||||
func (*ActivityLogMockInput) Descriptor() ([]byte, []int) {
|
||||
return file_vault_activity_generation_generate_data_proto_rawDescGZIP(), []int{0}
|
||||
return file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *ActivityLogMockInput) GetWrite() []WriteOptions {
|
||||
@@ -159,7 +159,7 @@ type Data struct {
|
||||
func (x *Data) Reset() {
|
||||
*x = Data{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_vault_activity_generation_generate_data_proto_msgTypes[1]
|
||||
mi := &file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -172,7 +172,7 @@ func (x *Data) String() string {
|
||||
func (*Data) ProtoMessage() {}
|
||||
|
||||
func (x *Data) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_vault_activity_generation_generate_data_proto_msgTypes[1]
|
||||
mi := &file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -185,7 +185,7 @@ func (x *Data) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Data.ProtoReflect.Descriptor instead.
|
||||
func (*Data) Descriptor() ([]byte, []int) {
|
||||
return file_vault_activity_generation_generate_data_proto_rawDescGZIP(), []int{1}
|
||||
return file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (m *Data) GetMonth() isData_Month {
|
||||
@@ -294,7 +294,7 @@ type Segments struct {
|
||||
func (x *Segments) Reset() {
|
||||
*x = Segments{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_vault_activity_generation_generate_data_proto_msgTypes[2]
|
||||
mi := &file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -307,7 +307,7 @@ func (x *Segments) String() string {
|
||||
func (*Segments) ProtoMessage() {}
|
||||
|
||||
func (x *Segments) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_vault_activity_generation_generate_data_proto_msgTypes[2]
|
||||
mi := &file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -320,7 +320,7 @@ func (x *Segments) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Segments.ProtoReflect.Descriptor instead.
|
||||
func (*Segments) Descriptor() ([]byte, []int) {
|
||||
return file_vault_activity_generation_generate_data_proto_rawDescGZIP(), []int{2}
|
||||
return file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Segments) GetSegments() []*Segment {
|
||||
@@ -342,7 +342,7 @@ type Segment struct {
|
||||
func (x *Segment) Reset() {
|
||||
*x = Segment{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_vault_activity_generation_generate_data_proto_msgTypes[3]
|
||||
mi := &file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -355,7 +355,7 @@ func (x *Segment) String() string {
|
||||
func (*Segment) ProtoMessage() {}
|
||||
|
||||
func (x *Segment) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_vault_activity_generation_generate_data_proto_msgTypes[3]
|
||||
mi := &file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -368,7 +368,7 @@ func (x *Segment) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Segment.ProtoReflect.Descriptor instead.
|
||||
func (*Segment) Descriptor() ([]byte, []int) {
|
||||
return file_vault_activity_generation_generate_data_proto_rawDescGZIP(), []int{3}
|
||||
return file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *Segment) GetSegmentIndex() int32 {
|
||||
@@ -396,7 +396,7 @@ type Clients struct {
|
||||
func (x *Clients) Reset() {
|
||||
*x = Clients{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_vault_activity_generation_generate_data_proto_msgTypes[4]
|
||||
mi := &file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -409,7 +409,7 @@ func (x *Clients) String() string {
|
||||
func (*Clients) ProtoMessage() {}
|
||||
|
||||
func (x *Clients) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_vault_activity_generation_generate_data_proto_msgTypes[4]
|
||||
mi := &file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -422,7 +422,7 @@ func (x *Clients) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Clients.ProtoReflect.Descriptor instead.
|
||||
func (*Clients) Descriptor() ([]byte, []int) {
|
||||
return file_vault_activity_generation_generate_data_proto_rawDescGZIP(), []int{4}
|
||||
return file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *Clients) GetClients() []*Client {
|
||||
@@ -449,7 +449,7 @@ type Client struct {
|
||||
func (x *Client) Reset() {
|
||||
*x = Client{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_vault_activity_generation_generate_data_proto_msgTypes[5]
|
||||
mi := &file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -462,7 +462,7 @@ func (x *Client) String() string {
|
||||
func (*Client) ProtoMessage() {}
|
||||
|
||||
func (x *Client) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_vault_activity_generation_generate_data_proto_msgTypes[5]
|
||||
mi := &file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -475,7 +475,7 @@ func (x *Client) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Client.ProtoReflect.Descriptor instead.
|
||||
func (*Client) Descriptor() ([]byte, []int) {
|
||||
return file_vault_activity_generation_generate_data_proto_rawDescGZIP(), []int{5}
|
||||
return file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *Client) GetId() string {
|
||||
@@ -527,100 +527,101 @@ func (x *Client) GetNonEntity() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var File_vault_activity_generation_generate_data_proto protoreflect.FileDescriptor
|
||||
var File_sdk_helper_clientcountutil_generation_generate_data_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_vault_activity_generation_generate_data_proto_rawDesc = []byte{
|
||||
0x0a, 0x2d, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79,
|
||||
0x2f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x67, 0x65, 0x6e, 0x65,
|
||||
0x72, 0x61, 0x74, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||
0x0a, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x6c, 0x0a, 0x14, 0x41,
|
||||
0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x6f, 0x67, 0x4d, 0x6f, 0x63, 0x6b, 0x49, 0x6e,
|
||||
0x70, 0x75, 0x74, 0x12, 0x2e, 0x0a, 0x05, 0x77, 0x72, 0x69, 0x74, 0x65, 0x18, 0x01, 0x20, 0x03,
|
||||
0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e,
|
||||
0x57, 0x72, 0x69, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x05, 0x77, 0x72,
|
||||
0x69, 0x74, 0x65, 0x12, 0x24, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x03, 0x28,
|
||||
0x0b, 0x32, 0x10, 0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44,
|
||||
0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xc8, 0x02, 0x0a, 0x04, 0x44, 0x61,
|
||||
0x74, 0x61, 0x12, 0x25, 0x0a, 0x0d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x6f,
|
||||
0x6e, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0c, 0x63, 0x75, 0x72,
|
||||
0x72, 0x65, 0x6e, 0x74, 0x4d, 0x6f, 0x6e, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0a, 0x6d, 0x6f, 0x6e,
|
||||
0x74, 0x68, 0x73, 0x5f, 0x61, 0x67, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52,
|
||||
0x09, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x73, 0x41, 0x67, 0x6f, 0x12, 0x27, 0x0a, 0x03, 0x61, 0x6c,
|
||||
0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x48, 0x01, 0x52, 0x03,
|
||||
0x61, 0x6c, 0x6c, 0x12, 0x32, 0x0a, 0x08, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18,
|
||||
0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x48, 0x01, 0x52, 0x08, 0x73,
|
||||
0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x32, 0x0a, 0x15, 0x65, 0x6d, 0x70, 0x74, 0x79,
|
||||
0x5f, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73,
|
||||
0x18, 0x05, 0x20, 0x03, 0x28, 0x05, 0x52, 0x13, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x53, 0x65, 0x67,
|
||||
0x6d, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x14, 0x73,
|
||||
0x6b, 0x69, 0x70, 0x5f, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65,
|
||||
0x78, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x05, 0x52, 0x12, 0x73, 0x6b, 0x69, 0x70, 0x53,
|
||||
0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x12, 0x21, 0x0a,
|
||||
0x0c, 0x6e, 0x75, 0x6d, 0x5f, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x07, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x0b, 0x6e, 0x75, 0x6d, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73,
|
||||
0x42, 0x07, 0x0a, 0x05, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x42, 0x09, 0x0a, 0x07, 0x63, 0x6c, 0x69,
|
||||
0x65, 0x6e, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x08, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73,
|
||||
0x12, 0x2f, 0x0a, 0x08, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03,
|
||||
0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e,
|
||||
0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74,
|
||||
0x73, 0x22, 0x74, 0x0a, 0x07, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x0d,
|
||||
0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x0c, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x6e,
|
||||
0x64, 0x65, 0x78, 0x88, 0x01, 0x01, 0x12, 0x2d, 0x0a, 0x07, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74,
|
||||
0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x07, 0x63, 0x6c,
|
||||
0x69, 0x65, 0x6e, 0x74, 0x73, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e,
|
||||
0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x22, 0x37, 0x0a, 0x07, 0x43, 0x6c, 0x69, 0x65, 0x6e,
|
||||
0x74, 0x73, 0x12, 0x2c, 0x0a, 0x07, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20,
|
||||
0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x07, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73,
|
||||
0x22, 0xcd, 0x01, 0x0a, 0x06, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69,
|
||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x2e, 0x0a,
|
||||
0x13, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x6d,
|
||||
0x6f, 0x6e, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x65,
|
||||
0x61, 0x74, 0x65, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x4d, 0x6f, 0x6e, 0x74, 0x68, 0x12, 0x1c, 0x0a,
|
||||
0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6d,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6d, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18,
|
||||
0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6e, 0x6f, 0x6e, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79,
|
||||
0x2a, 0xa0, 0x01, 0x0a, 0x0c, 0x57, 0x72, 0x69, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x12, 0x11, 0x0a, 0x0d, 0x57, 0x52, 0x49, 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f,
|
||||
0x57, 0x4e, 0x10, 0x00, 0x12, 0x1d, 0x0a, 0x19, 0x57, 0x52, 0x49, 0x54, 0x45, 0x5f, 0x50, 0x52,
|
||||
0x45, 0x43, 0x4f, 0x4d, 0x50, 0x55, 0x54, 0x45, 0x44, 0x5f, 0x51, 0x55, 0x45, 0x52, 0x49, 0x45,
|
||||
0x53, 0x10, 0x01, 0x12, 0x1a, 0x0a, 0x16, 0x57, 0x52, 0x49, 0x54, 0x45, 0x5f, 0x44, 0x49, 0x53,
|
||||
0x54, 0x49, 0x4e, 0x43, 0x54, 0x5f, 0x43, 0x4c, 0x49, 0x45, 0x4e, 0x54, 0x53, 0x10, 0x02, 0x12,
|
||||
0x12, 0x0a, 0x0e, 0x57, 0x52, 0x49, 0x54, 0x45, 0x5f, 0x45, 0x4e, 0x54, 0x49, 0x54, 0x49, 0x45,
|
||||
0x53, 0x10, 0x03, 0x12, 0x17, 0x0a, 0x13, 0x57, 0x52, 0x49, 0x54, 0x45, 0x5f, 0x44, 0x49, 0x52,
|
||||
0x45, 0x43, 0x54, 0x5f, 0x54, 0x4f, 0x4b, 0x45, 0x4e, 0x53, 0x10, 0x04, 0x12, 0x15, 0x0a, 0x11,
|
||||
0x57, 0x52, 0x49, 0x54, 0x45, 0x5f, 0x49, 0x4e, 0x54, 0x45, 0x4e, 0x54, 0x5f, 0x4c, 0x4f, 0x47,
|
||||
0x53, 0x10, 0x05, 0x42, 0x36, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
||||
0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x76, 0x61, 0x75, 0x6c,
|
||||
0x74, 0x2f, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79,
|
||||
0x2f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
var file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDesc = []byte{
|
||||
0x0a, 0x39, 0x73, 0x64, 0x6b, 0x2f, 0x68, 0x65, 0x6c, 0x70, 0x65, 0x72, 0x2f, 0x63, 0x6c, 0x69,
|
||||
0x65, 0x6e, 0x74, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x75, 0x74, 0x69, 0x6c, 0x2f, 0x67, 0x65, 0x6e,
|
||||
0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65,
|
||||
0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x67, 0x65, 0x6e,
|
||||
0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x6c, 0x0a, 0x14, 0x41, 0x63, 0x74, 0x69, 0x76,
|
||||
0x69, 0x74, 0x79, 0x4c, 0x6f, 0x67, 0x4d, 0x6f, 0x63, 0x6b, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12,
|
||||
0x2e, 0x0a, 0x05, 0x77, 0x72, 0x69, 0x74, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18,
|
||||
0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x57, 0x72, 0x69, 0x74,
|
||||
0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x05, 0x77, 0x72, 0x69, 0x74, 0x65, 0x12,
|
||||
0x24, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e,
|
||||
0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52,
|
||||
0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xc8, 0x02, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x25,
|
||||
0x0a, 0x0d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74,
|
||||
0x4d, 0x6f, 0x6e, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0a, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x73, 0x5f,
|
||||
0x61, 0x67, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x09, 0x6d, 0x6f, 0x6e,
|
||||
0x74, 0x68, 0x73, 0x41, 0x67, 0x6f, 0x12, 0x27, 0x0a, 0x03, 0x61, 0x6c, 0x6c, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x48, 0x01, 0x52, 0x03, 0x61, 0x6c, 0x6c, 0x12,
|
||||
0x32, 0x0a, 0x08, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||
0x0b, 0x32, 0x14, 0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53,
|
||||
0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x48, 0x01, 0x52, 0x08, 0x73, 0x65, 0x67, 0x6d, 0x65,
|
||||
0x6e, 0x74, 0x73, 0x12, 0x32, 0x0a, 0x15, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x5f, 0x73, 0x65, 0x67,
|
||||
0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03,
|
||||
0x28, 0x05, 0x52, 0x13, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74,
|
||||
0x49, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x14, 0x73, 0x6b, 0x69, 0x70, 0x5f,
|
||||
0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x18,
|
||||
0x06, 0x20, 0x03, 0x28, 0x05, 0x52, 0x12, 0x73, 0x6b, 0x69, 0x70, 0x53, 0x65, 0x67, 0x6d, 0x65,
|
||||
0x6e, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x6e, 0x75, 0x6d,
|
||||
0x5f, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x0b, 0x6e, 0x75, 0x6d, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x42, 0x07, 0x0a, 0x05,
|
||||
0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x42, 0x09, 0x0a, 0x07, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73,
|
||||
0x22, 0x3b, 0x0a, 0x08, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x08,
|
||||
0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13,
|
||||
0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x67, 0x6d,
|
||||
0x65, 0x6e, 0x74, 0x52, 0x08, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x74, 0x0a,
|
||||
0x07, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x0d, 0x73, 0x65, 0x67, 0x6d,
|
||||
0x65, 0x6e, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x48,
|
||||
0x00, 0x52, 0x0c, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x88,
|
||||
0x01, 0x01, 0x12, 0x2d, 0x0a, 0x07, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x07, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74,
|
||||
0x73, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x6e,
|
||||
0x64, 0x65, 0x78, 0x22, 0x37, 0x0a, 0x07, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2c,
|
||||
0x0a, 0x07, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
|
||||
0x12, 0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x6c, 0x69,
|
||||
0x65, 0x6e, 0x74, 0x52, 0x07, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xcd, 0x01, 0x0a,
|
||||
0x06, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a,
|
||||
0x08, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52,
|
||||
0x08, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x2e, 0x0a, 0x13, 0x72, 0x65, 0x70,
|
||||
0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x6d, 0x6f, 0x6e, 0x74, 0x68,
|
||||
0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64,
|
||||
0x46, 0x72, 0x6f, 0x6d, 0x4d, 0x6f, 0x6e, 0x74, 0x68, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d,
|
||||
0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61,
|
||||
0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1d, 0x0a,
|
||||
0x0a, 0x6e, 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28,
|
||||
0x08, 0x52, 0x09, 0x6e, 0x6f, 0x6e, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2a, 0xa0, 0x01, 0x0a,
|
||||
0x0c, 0x57, 0x72, 0x69, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x11, 0x0a,
|
||||
0x0d, 0x57, 0x52, 0x49, 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00,
|
||||
0x12, 0x1d, 0x0a, 0x19, 0x57, 0x52, 0x49, 0x54, 0x45, 0x5f, 0x50, 0x52, 0x45, 0x43, 0x4f, 0x4d,
|
||||
0x50, 0x55, 0x54, 0x45, 0x44, 0x5f, 0x51, 0x55, 0x45, 0x52, 0x49, 0x45, 0x53, 0x10, 0x01, 0x12,
|
||||
0x1a, 0x0a, 0x16, 0x57, 0x52, 0x49, 0x54, 0x45, 0x5f, 0x44, 0x49, 0x53, 0x54, 0x49, 0x4e, 0x43,
|
||||
0x54, 0x5f, 0x43, 0x4c, 0x49, 0x45, 0x4e, 0x54, 0x53, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x57,
|
||||
0x52, 0x49, 0x54, 0x45, 0x5f, 0x45, 0x4e, 0x54, 0x49, 0x54, 0x49, 0x45, 0x53, 0x10, 0x03, 0x12,
|
||||
0x17, 0x0a, 0x13, 0x57, 0x52, 0x49, 0x54, 0x45, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x5f,
|
||||
0x54, 0x4f, 0x4b, 0x45, 0x4e, 0x53, 0x10, 0x04, 0x12, 0x15, 0x0a, 0x11, 0x57, 0x52, 0x49, 0x54,
|
||||
0x45, 0x5f, 0x49, 0x4e, 0x54, 0x45, 0x4e, 0x54, 0x5f, 0x4c, 0x4f, 0x47, 0x53, 0x10, 0x05, 0x42,
|
||||
0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61,
|
||||
0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2f, 0x73, 0x64,
|
||||
0x6b, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x75, 0x74, 0x69,
|
||||
0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_vault_activity_generation_generate_data_proto_rawDescOnce sync.Once
|
||||
file_vault_activity_generation_generate_data_proto_rawDescData = file_vault_activity_generation_generate_data_proto_rawDesc
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescOnce sync.Once
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescData = file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_vault_activity_generation_generate_data_proto_rawDescGZIP() []byte {
|
||||
file_vault_activity_generation_generate_data_proto_rawDescOnce.Do(func() {
|
||||
file_vault_activity_generation_generate_data_proto_rawDescData = protoimpl.X.CompressGZIP(file_vault_activity_generation_generate_data_proto_rawDescData)
|
||||
func file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescGZIP() []byte {
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescOnce.Do(func() {
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescData = protoimpl.X.CompressGZIP(file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescData)
|
||||
})
|
||||
return file_vault_activity_generation_generate_data_proto_rawDescData
|
||||
return file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_vault_activity_generation_generate_data_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_vault_activity_generation_generate_data_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_vault_activity_generation_generate_data_proto_goTypes = []interface{}{
|
||||
var file_sdk_helper_clientcountutil_generation_generate_data_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_sdk_helper_clientcountutil_generation_generate_data_proto_goTypes = []interface{}{
|
||||
(WriteOptions)(0), // 0: generation.WriteOptions
|
||||
(*ActivityLogMockInput)(nil), // 1: generation.ActivityLogMockInput
|
||||
(*Data)(nil), // 2: generation.Data
|
||||
@@ -629,7 +630,7 @@ var file_vault_activity_generation_generate_data_proto_goTypes = []interface{}{
|
||||
(*Clients)(nil), // 5: generation.Clients
|
||||
(*Client)(nil), // 6: generation.Client
|
||||
}
|
||||
var file_vault_activity_generation_generate_data_proto_depIdxs = []int32{
|
||||
var file_sdk_helper_clientcountutil_generation_generate_data_proto_depIdxs = []int32{
|
||||
0, // 0: generation.ActivityLogMockInput.write:type_name -> generation.WriteOptions
|
||||
2, // 1: generation.ActivityLogMockInput.data:type_name -> generation.Data
|
||||
5, // 2: generation.Data.all:type_name -> generation.Clients
|
||||
@@ -644,13 +645,13 @@ var file_vault_activity_generation_generate_data_proto_depIdxs = []int32{
|
||||
0, // [0:7] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_vault_activity_generation_generate_data_proto_init() }
|
||||
func file_vault_activity_generation_generate_data_proto_init() {
|
||||
if File_vault_activity_generation_generate_data_proto != nil {
|
||||
func init() { file_sdk_helper_clientcountutil_generation_generate_data_proto_init() }
|
||||
func file_sdk_helper_clientcountutil_generation_generate_data_proto_init() {
|
||||
if File_sdk_helper_clientcountutil_generation_generate_data_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_vault_activity_generation_generate_data_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ActivityLogMockInput); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -662,7 +663,7 @@ func file_vault_activity_generation_generate_data_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_vault_activity_generation_generate_data_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Data); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -674,7 +675,7 @@ func file_vault_activity_generation_generate_data_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_vault_activity_generation_generate_data_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Segments); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -686,7 +687,7 @@ func file_vault_activity_generation_generate_data_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_vault_activity_generation_generate_data_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Segment); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -698,7 +699,7 @@ func file_vault_activity_generation_generate_data_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_vault_activity_generation_generate_data_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Clients); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -710,7 +711,7 @@ func file_vault_activity_generation_generate_data_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_vault_activity_generation_generate_data_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Client); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -723,30 +724,30 @@ func file_vault_activity_generation_generate_data_proto_init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
file_vault_activity_generation_generate_data_proto_msgTypes[1].OneofWrappers = []interface{}{
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[1].OneofWrappers = []interface{}{
|
||||
(*Data_CurrentMonth)(nil),
|
||||
(*Data_MonthsAgo)(nil),
|
||||
(*Data_All)(nil),
|
||||
(*Data_Segments)(nil),
|
||||
}
|
||||
file_vault_activity_generation_generate_data_proto_msgTypes[3].OneofWrappers = []interface{}{}
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes[3].OneofWrappers = []interface{}{}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_vault_activity_generation_generate_data_proto_rawDesc,
|
||||
RawDescriptor: file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 6,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_vault_activity_generation_generate_data_proto_goTypes,
|
||||
DependencyIndexes: file_vault_activity_generation_generate_data_proto_depIdxs,
|
||||
EnumInfos: file_vault_activity_generation_generate_data_proto_enumTypes,
|
||||
MessageInfos: file_vault_activity_generation_generate_data_proto_msgTypes,
|
||||
GoTypes: file_sdk_helper_clientcountutil_generation_generate_data_proto_goTypes,
|
||||
DependencyIndexes: file_sdk_helper_clientcountutil_generation_generate_data_proto_depIdxs,
|
||||
EnumInfos: file_sdk_helper_clientcountutil_generation_generate_data_proto_enumTypes,
|
||||
MessageInfos: file_sdk_helper_clientcountutil_generation_generate_data_proto_msgTypes,
|
||||
}.Build()
|
||||
File_vault_activity_generation_generate_data_proto = out.File
|
||||
file_vault_activity_generation_generate_data_proto_rawDesc = nil
|
||||
file_vault_activity_generation_generate_data_proto_goTypes = nil
|
||||
file_vault_activity_generation_generate_data_proto_depIdxs = nil
|
||||
File_sdk_helper_clientcountutil_generation_generate_data_proto = out.File
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_rawDesc = nil
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_goTypes = nil
|
||||
file_sdk_helper_clientcountutil_generation_generate_data_proto_depIdxs = nil
|
||||
}
|
||||
@@ -5,7 +5,7 @@ syntax = "proto3";
|
||||
|
||||
package generation;
|
||||
|
||||
option go_package = "github.com/hashicorp/vault/vault/activity/generation";
|
||||
option go_package = "github.com/hashicorp/vault/sdk/clientcountutil/generation";
|
||||
enum WriteOptions {
|
||||
WRITE_UNKNOWN = 0;
|
||||
WRITE_PRECOMPUTED_QUERIES = 1;
|
||||
@@ -16,9 +16,10 @@ import (
|
||||
"github.com/hashicorp/vault/helper/namespace"
|
||||
"github.com/hashicorp/vault/helper/timeutil"
|
||||
"github.com/hashicorp/vault/sdk/framework"
|
||||
"github.com/hashicorp/vault/sdk/helper/clientcountutil"
|
||||
"github.com/hashicorp/vault/sdk/helper/clientcountutil/generation"
|
||||
"github.com/hashicorp/vault/sdk/logical"
|
||||
"github.com/hashicorp/vault/vault/activity"
|
||||
"github.com/hashicorp/vault/vault/activity/generation"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
@@ -58,6 +59,11 @@ func (b *SystemBackend) handleActivityWriteData(ctx context.Context, request *lo
|
||||
return logical.ErrorResponse("Missing required \"data\" values"), logical.ErrInvalidRequest
|
||||
}
|
||||
|
||||
err = clientcountutil.VerifyInput(input)
|
||||
if err != nil {
|
||||
return logical.ErrorResponse("Invalid input data: %s", err), logical.ErrInvalidRequest
|
||||
}
|
||||
|
||||
numMonths := 0
|
||||
for _, month := range input.Data {
|
||||
if int(month.GetMonthsAgo()) > numMonths {
|
||||
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
|
||||
"github.com/hashicorp/vault/helper/namespace"
|
||||
"github.com/hashicorp/vault/helper/timeutil"
|
||||
"github.com/hashicorp/vault/sdk/helper/clientcountutil/generation"
|
||||
"github.com/hashicorp/vault/sdk/logical"
|
||||
"github.com/hashicorp/vault/vault/activity"
|
||||
"github.com/hashicorp/vault/vault/activity/generation"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
Reference in New Issue
Block a user