Skip to content

Commit

Permalink
Fix non-expiring cache for cluster config
Browse files Browse the repository at this point in the history
This PR fixes #2166, adds suite tests.
  • Loading branch information
klizhentas committed Aug 14, 2018
1 parent 28a5ffd commit 49b9ce4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/auth/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,16 @@ func (s *TLSSuite) TestAuthPreference(c *check.C) {
suite.AuthPreference(c)
}

func (s *TLSSuite) TestClusterConfig(c *check.C) {
clt, err := s.server.NewClient(TestAdmin())
c.Assert(err, check.IsNil)

suite := &suite.ServicesTestSuite{
ConfigS: clt,
}
suite.ClusterConfig(c)
}

func (s *TLSSuite) TestTunnelConnectionsCRUD(c *check.C) {
clt, err := s.server.NewClient(TestAdmin())
c.Assert(err, check.IsNil)
Expand Down
6 changes: 6 additions & 0 deletions lib/services/clusterconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@ const ClusterConfigSpecSchemaTemplate = `{
"cluster_id": {
"type": "string"
},
"client_idle_timeout": {
"type": "string"
},
"disconnect_expired_cert": {
"anyOf": [{"type": "string"}, { "type": "boolean"}]
},
"audit": {
"type": "object",
"additionalProperties": false,
Expand Down
7 changes: 7 additions & 0 deletions lib/services/local/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ func (s *ClusterConfigurationSuite) TestAuthPreference(c *check.C) {
suite.AuthPreference(c)
}

func (s *ClusterConfigurationSuite) TestClusterConfig(c *check.C) {
suite := &suite.ServicesTestSuite{
ConfigS: NewClusterConfigurationService(s.bk),
}
suite.ClusterConfig(c)
}

func (s *ClusterConfigurationSuite) TestSessionRecording(c *check.C) {
// don't allow invalid session recording values
clusterConfig, err := services.NewClusterConfig(services.ClusterConfigSpecV3{
Expand Down
26 changes: 26 additions & 0 deletions lib/services/suite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,3 +780,29 @@ func (s *ServicesTestSuite) AuthPreference(c *C) {
c.Assert(gotAP.GetType(), Equals, "local")
c.Assert(gotAP.GetSecondFactor(), Equals, "otp")
}

// ClusterConfig tests cluster configuration
func (s *ServicesTestSuite) ClusterConfig(c *C) {
config, err := services.NewClusterConfig(services.ClusterConfigSpecV3{
ClientIdleTimeout: services.NewDuration(17 * time.Second),
DisconnectExpiredCert: services.NewBool(true),
ClusterID: "27",
SessionRecording: services.RecordAtProxy,
Audit: services.AuditConfig{
Region: "us-west-1",
Type: "dynamodb",
AuditSessionsURI: "file:///home/log",
AuditTableName: "audit_table_name",
AuditEventsURI: []string{"dynamodb://audit_table_name", "file:///home/log"},
},
})
c.Assert(err, IsNil)

err = s.ConfigS.SetClusterConfig(config)
c.Assert(err, IsNil)

gotConfig, err := s.ConfigS.GetClusterConfig()
c.Assert(err, IsNil)

fixtures.DeepCompare(c, config, gotConfig)
}

0 comments on commit 49b9ce4

Please sign in to comment.