2017-02-08 15:06:19 +00:00
|
|
|
package enterprise_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
|
|
|
"net/url"
|
|
|
|
|
2020-04-03 17:39:20 +00:00
|
|
|
"github.com/influxdata/influxdb/v2/chronograf"
|
|
|
|
"github.com/influxdata/influxdb/v2/chronograf/enterprise"
|
2017-02-08 15:06:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ControlClient struct {
|
|
|
|
Cluster *enterprise.Cluster
|
|
|
|
ShowClustersCalled bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMockControlClient(addr string) *ControlClient {
|
|
|
|
_, err := url.Parse(addr)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &ControlClient{
|
|
|
|
Cluster: &enterprise.Cluster{
|
|
|
|
DataNodes: []enterprise.DataNode{
|
|
|
|
enterprise.DataNode{
|
|
|
|
HTTPAddr: addr,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-17 19:37:00 +00:00
|
|
|
func (cc *ControlClient) ShowCluster(context.Context) (*enterprise.Cluster, error) {
|
2017-02-08 15:06:19 +00:00
|
|
|
cc.ShowClustersCalled = true
|
|
|
|
return cc.Cluster, nil
|
|
|
|
}
|
|
|
|
|
2017-02-17 19:37:00 +00:00
|
|
|
func (cc *ControlClient) User(ctx context.Context, name string) (*enterprise.User, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
2017-02-17 21:13:51 +00:00
|
|
|
|
2017-02-17 19:37:00 +00:00
|
|
|
func (cc *ControlClient) CreateUser(ctx context.Context, name, passwd string) error {
|
|
|
|
return nil
|
|
|
|
}
|
2017-02-17 21:13:51 +00:00
|
|
|
|
2017-02-17 19:37:00 +00:00
|
|
|
func (cc *ControlClient) DeleteUser(ctx context.Context, name string) error {
|
|
|
|
return nil
|
|
|
|
}
|
2017-02-17 21:13:51 +00:00
|
|
|
|
2017-02-17 19:37:00 +00:00
|
|
|
func (cc *ControlClient) ChangePassword(ctx context.Context, name, passwd string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-02-17 21:13:51 +00:00
|
|
|
func (cc *ControlClient) Users(ctx context.Context, name *string) (*enterprise.Users, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2017-02-17 22:35:56 +00:00
|
|
|
func (cc *ControlClient) SetUserPerms(ctx context.Context, name string, perms enterprise.Permissions) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-02-23 22:02:53 +00:00
|
|
|
func (cc *ControlClient) CreateRole(ctx context.Context, name string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cc *ControlClient) Role(ctx context.Context, name string) (*enterprise.Role, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2017-03-02 01:13:44 +00:00
|
|
|
func (ccm *ControlClient) UserRoles(ctx context.Context) (map[string]enterprise.Roles, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2017-02-23 22:02:53 +00:00
|
|
|
func (ccm *ControlClient) Roles(ctx context.Context, name *string) (*enterprise.Roles, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cc *ControlClient) DeleteRole(ctx context.Context, name string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cc *ControlClient) SetRolePerms(ctx context.Context, name string, perms enterprise.Permissions) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cc *ControlClient) SetRoleUsers(ctx context.Context, name string, users []string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-03-10 22:52:24 +00:00
|
|
|
func (cc *ControlClient) AddRoleUsers(ctx context.Context, name string, users []string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cc *ControlClient) RemoveRoleUsers(ctx context.Context, name string, users []string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-02-08 15:06:19 +00:00
|
|
|
type TimeSeries struct {
|
|
|
|
URLs []string
|
|
|
|
Response Response
|
|
|
|
|
|
|
|
QueryCtr int
|
|
|
|
}
|
|
|
|
|
|
|
|
type Response struct{}
|
|
|
|
|
|
|
|
func (r *Response) MarshalJSON() ([]byte, error) {
|
|
|
|
return json.Marshal(r)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ts *TimeSeries) Query(ctx context.Context, q chronograf.Query) (chronograf.Response, error) {
|
|
|
|
ts.QueryCtr++
|
|
|
|
return &Response{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ts *TimeSeries) Connect(ctx context.Context, src *chronograf.Source) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-02-27 19:27:17 +00:00
|
|
|
func (ts *TimeSeries) Write(ctx context.Context, points []chronograf.Point) error {
|
2018-01-12 23:17:14 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-02-17 19:37:00 +00:00
|
|
|
func (ts *TimeSeries) Users(ctx context.Context) chronograf.UsersStore {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-02-23 22:02:53 +00:00
|
|
|
func (ts *TimeSeries) Roles(ctx context.Context) (chronograf.RolesStore, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2017-02-27 19:31:38 +00:00
|
|
|
func (ts *TimeSeries) Permissions(ctx context.Context) chronograf.Permissions {
|
|
|
|
return chronograf.Permissions{}
|
2017-02-19 19:47:19 +00:00
|
|
|
}
|
|
|
|
|
2017-02-08 15:06:19 +00:00
|
|
|
func NewMockTimeSeries(urls ...string) *TimeSeries {
|
|
|
|
return &TimeSeries{
|
|
|
|
URLs: urls,
|
|
|
|
Response: Response{},
|
|
|
|
}
|
|
|
|
}
|