Complete 9ef1e57 by removing Role concept from sources in server
parent
63d4f70d11
commit
7588dcbf63
|
@ -30,7 +30,6 @@ func TestSourceStore(t *testing.T) {
|
|||
URL: "toyota-hilux.lyon-estates.local",
|
||||
Default: true,
|
||||
Organization: "1337",
|
||||
Role: "member",
|
||||
},
|
||||
chronograf.Source{
|
||||
Name: "HipToBeSquare",
|
||||
|
@ -40,7 +39,6 @@ func TestSourceStore(t *testing.T) {
|
|||
URL: "toyota-hilux.lyon-estates.local",
|
||||
Default: true,
|
||||
Organization: "1337",
|
||||
Role: "admin",
|
||||
},
|
||||
chronograf.Source{
|
||||
Name: "HipToBeSquare",
|
||||
|
@ -51,7 +49,6 @@ func TestSourceStore(t *testing.T) {
|
|||
InsecureSkipVerify: true,
|
||||
Default: false,
|
||||
Organization: "1337",
|
||||
Role: "viewer",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/bouk/httprouter"
|
||||
"github.com/influxdata/chronograf"
|
||||
"github.com/influxdata/chronograf/influx"
|
||||
"github.com/influxdata/chronograf/roles"
|
||||
)
|
||||
|
||||
type sourceLinks struct {
|
||||
|
@ -260,9 +259,6 @@ func (s *Service) UpdateSource(w http.ResponseWriter, r *http.Request) {
|
|||
if req.Telegraf != "" {
|
||||
src.Telegraf = req.Telegraf
|
||||
}
|
||||
if req.Role != "" {
|
||||
src.Role = req.Role
|
||||
}
|
||||
|
||||
defaultOrg, err := s.Store.Organizations(ctx).DefaultOrganization(ctx)
|
||||
if err != nil {
|
||||
|
@ -318,17 +314,6 @@ func ValidSourceRequest(s *chronograf.Source, defaultOrgID string) error {
|
|||
return fmt.Errorf("Invalid URL; no URL scheme defined")
|
||||
}
|
||||
|
||||
if s.Role == "" {
|
||||
s.Role = roles.ViewerRoleName
|
||||
}
|
||||
|
||||
switch s.Role {
|
||||
case roles.ViewerRoleName, roles.EditorRoleName, roles.AdminRoleName:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("Unknown role %s. Valid roles are 'viewer', 'editor', and 'admin'", s.Role)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import (
|
|||
"github.com/influxdata/chronograf"
|
||||
"github.com/influxdata/chronograf/log"
|
||||
"github.com/influxdata/chronograf/mocks"
|
||||
"github.com/influxdata/chronograf/roles"
|
||||
)
|
||||
|
||||
func Test_ValidSourceRequest(t *testing.T) {
|
||||
|
@ -54,7 +53,6 @@ func Test_ValidSourceRequest(t *testing.T) {
|
|||
Default: true,
|
||||
Telegraf: "telegraf",
|
||||
Organization: "0",
|
||||
Role: roles.ViewerRoleName,
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
|
@ -77,7 +75,6 @@ func Test_ValidSourceRequest(t *testing.T) {
|
|||
Default: true,
|
||||
Telegraf: "telegraf",
|
||||
Organization: "0",
|
||||
Role: roles.ViewerRoleName,
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
|
@ -100,7 +97,6 @@ func Test_ValidSourceRequest(t *testing.T) {
|
|||
InsecureSkipVerify: true,
|
||||
Default: true,
|
||||
Telegraf: "telegraf",
|
||||
Role: roles.ViewerRoleName,
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
|
@ -117,7 +113,6 @@ func Test_ValidSourceRequest(t *testing.T) {
|
|||
Default: true,
|
||||
Organization: "2",
|
||||
Telegraf: "telegraf",
|
||||
Role: roles.ViewerRoleName,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -137,72 +132,12 @@ func Test_ValidSourceRequest(t *testing.T) {
|
|||
Organization: "0",
|
||||
Default: true,
|
||||
Telegraf: "telegraf",
|
||||
Role: roles.ViewerRoleName,
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
err: fmt.Errorf("invalid source URI: parse im a bad url: invalid URI for request"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "set Role to be viewer if not specified",
|
||||
args: args{
|
||||
source: &chronograf.Source{
|
||||
ID: 1,
|
||||
Name: "I'm a really great source",
|
||||
Type: chronograf.InfluxDB,
|
||||
Username: "fancy",
|
||||
Password: "i'm so",
|
||||
SharedSecret: "supersecret",
|
||||
URL: "http://www.any.url.com",
|
||||
MetaURL: "http://www.so.meta.com",
|
||||
InsecureSkipVerify: true,
|
||||
Default: true,
|
||||
Telegraf: "telegraf",
|
||||
Organization: "0",
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
source: &chronograf.Source{
|
||||
ID: 1,
|
||||
Name: "I'm a really great source",
|
||||
Type: chronograf.InfluxDB,
|
||||
Username: "fancy",
|
||||
Password: "i'm so",
|
||||
SharedSecret: "supersecret",
|
||||
URL: "http://www.any.url.com",
|
||||
MetaURL: "http://www.so.meta.com",
|
||||
InsecureSkipVerify: true,
|
||||
Default: true,
|
||||
Organization: "0",
|
||||
Telegraf: "telegraf",
|
||||
Role: roles.ViewerRoleName,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bad role type",
|
||||
args: args{
|
||||
source: &chronograf.Source{
|
||||
ID: 1,
|
||||
Name: "I'm a really great source",
|
||||
Type: chronograf.InfluxDB,
|
||||
Username: "fancy",
|
||||
Password: "i'm so",
|
||||
SharedSecret: "supersecret",
|
||||
URL: "http://www.any.url.com",
|
||||
MetaURL: "http://www.so.meta.com",
|
||||
InsecureSkipVerify: true,
|
||||
Default: true,
|
||||
Telegraf: "telegraf",
|
||||
Organization: "0",
|
||||
Role: "superperson",
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
err: fmt.Errorf("Unknown role superperson. Valid roles are 'viewer', 'editor', and 'admin'"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
Loading…
Reference in New Issue