Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integration: test lease revoke routine with JWT token #9773

Merged
merged 1 commit into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion integration/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ var (
ClientCertAuth: true,
}

defaultTokenJWT = "jwt,pub-key=./fixtures/server.crt,priv-key=./fixtures/server.key.insecure,sign-method=RS256,ttl=1s"

lg = zap.NewNop()
)

Expand All @@ -123,6 +125,8 @@ type ClusterConfig struct {

DiscoveryURL string

AuthToken string

UseGRPC bool

QuotaBackendBytes int64
Expand Down Expand Up @@ -272,6 +276,7 @@ func (c *cluster) mustNewMember(t *testing.T) *member {
m := mustNewMember(t,
memberConfig{
name: c.name(rand.Int()),
authToken: c.cfg.AuthToken,
peerTLS: c.cfg.PeerTLS,
clientTLS: c.cfg.ClientTLS,
quotaBackendBytes: c.cfg.QuotaBackendBytes,
Expand Down Expand Up @@ -557,6 +562,7 @@ type memberConfig struct {
name string
peerTLS *transport.TLSInfo
clientTLS *transport.TLSInfo
authToken string
quotaBackendBytes int64
maxTxnOps uint
maxRequestBytes uint
Expand Down Expand Up @@ -632,7 +638,13 @@ func mustNewMember(t *testing.T, mcfg memberConfig) *member {
if mcfg.snapshotCatchUpEntries != 0 {
m.SnapshotCatchUpEntries = mcfg.snapshotCatchUpEntries
}
m.AuthToken = "simple" // for the purpose of integration testing, simple token is enough

// for the purpose of integration testing, simple token is enough
m.AuthToken = "simple"
if mcfg.authToken != "" {
m.AuthToken = mcfg.authToken
}

m.BcryptCost = uint(bcrypt.MinCost) // use min bcrypt cost to speedy up integration testing

m.grpcServerOpts = []grpc.ServerOption{}
Expand Down
12 changes: 11 additions & 1 deletion integration/v3_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,19 @@ func TestV3AuthRevision(t *testing.T) {
// TestV3AuthWithLeaseRevokeWithRoot ensures that granted leases
// with root user be revoked after TTL.
func TestV3AuthWithLeaseRevokeWithRoot(t *testing.T) {
testV3AuthWithLeaseRevokeWithRoot(t, ClusterConfig{Size: 1})
}

// TestV3AuthWithLeaseRevokeWithRootJWT creates a lease with a JWT-token enabled cluster.
// And tests if server is able to revoke expiry lease item.
func TestV3AuthWithLeaseRevokeWithRootJWT(t *testing.T) {
testV3AuthWithLeaseRevokeWithRoot(t, ClusterConfig{Size: 1, AuthToken: defaultTokenJWT})
}

func testV3AuthWithLeaseRevokeWithRoot(t *testing.T, ccfg ClusterConfig) {
defer testutil.AfterTest(t)

clus := NewClusterV3(t, &ClusterConfig{Size: 1})
clus := NewClusterV3(t, &ccfg)
defer clus.Terminate(t)

api := toGRPC(clus.Client(0))
Expand Down