Created
July 2, 2018 05:49
-
-
Save mitsutaka/14462fca2d9df292fa46870d4e390195 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package neco_goconvey_test | |
import ( | |
"testing" | |
. "github.com/cybozu-go/neco-goconvey" | |
. "github.com/smartystreets/goconvey/convey" | |
) | |
func TestEtcdPasswd(t *testing.T) { | |
Convey("Test behavior of etcdpasswd", t, func() { | |
testUser := "bob" | |
testGroup := "bob" | |
Convey("etcdpasswd set start-uid 10000", func() { | |
stdout, stderr, err := RunOnRack0Boot("etcdpasswd", "set", "start-uid", "10000") | |
code := ExitCode(err) | |
So(code, ShouldBeZeroValue) | |
So(stdout.String(), ShouldBeBlank) | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
Convey("etcdpasswd set start-gid 10000", func() { | |
stdout, stderr, err := RunOnRack0Boot("etcdpasswd", "set", "start-gid", "10000") | |
code := ExitCode(err) | |
So(code, ShouldBeZeroValue) | |
So(stdout.String(), ShouldBeBlank) | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
Convey("etcdpasswd group add bob", func() { | |
stdout, stderr, err := RunOnRack0Boot("etcdpasswd", "group", "add", testGroup) | |
code := ExitCode(err) | |
So(code, ShouldBeZeroValue) | |
So(stdout.String(), ShouldBeBlank) | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
Convey("etcdpasswd user add -group bob bob", func() { | |
stdout, stderr, err := RunOnRack0Boot("etcdpasswd", "user", "add", "-group", testGroup, testUser) | |
code := ExitCode(err) | |
So(code, ShouldBeZeroValue) | |
So(stdout.String(), ShouldBeBlank) | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
Convey("etcdpasswd user list on rack0-boot", func() { | |
stdout, stderr, err := RunOnRack0Boot("etcdpasswd", "user", "list") | |
code := ExitCode(err) | |
So(code, ShouldBeZeroValue) | |
So(stdout.String(), ShouldEqual, testUser+"\n") | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
Convey("grep bob /etc/passwd on rack0-boot", func() { | |
stdout, stderr, err := RunOnRack0Boot("grep", testUser, "/etc/passwd") | |
code := ExitCode(err) | |
So(code, ShouldBeZeroValue) | |
So(stdout.String(), ShouldStartWith, testUser) | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
Convey("etcdpasswd user list on rack1-boot", func() { | |
stdout, stderr, err := RunOnRack1Boot("etcdpasswd", "user", "list") | |
code := ExitCode(err) | |
So(code, ShouldBeZeroValue) | |
So(stdout.String(), ShouldEqual, testUser+"\n") | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
Convey("grep bob /etc/passwd on rack1-boot", func() { | |
stdout, stderr, err := RunOnRack1Boot("grep", testUser, "/etc/passwd") | |
code := ExitCode(err) | |
So(code, ShouldBeZeroValue) | |
So(stdout.String(), ShouldStartWith, testUser) | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
Convey("etcdpasswd user list on rack2-boot", func() { | |
stdout, stderr, err := RunOnRack2Boot("etcdpasswd", "user", "list") | |
code := ExitCode(err) | |
So(code, ShouldBeZeroValue) | |
So(stdout.String(), ShouldEqual, testUser+"\n") | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
Convey("grep bob /etc/passwd on rack2-boot", func() { | |
stdout, stderr, err := RunOnRack1Boot("grep", testUser, "/etc/passwd") | |
code := ExitCode(err) | |
So(code, ShouldBeZeroValue) | |
So(stdout.String(), ShouldStartWith, testUser) | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
Convey("etcdpasswd user remove bob", func() { | |
stdout, stderr, err := RunOnRack0Boot("etcdpasswd", "user", "remove", testUser) | |
code := ExitCode(err) | |
So(code, ShouldBeZeroValue) | |
So(stdout.String(), ShouldBeBlank) | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
Convey("etcdpasswd group remove bob", func() { | |
stdout, stderr, err := RunOnRack0Boot("etcdpasswd", "group", "remove", testGroup) | |
code := ExitCode(err) | |
So(code, ShouldBeZeroValue) | |
So(stdout.String(), ShouldBeBlank) | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
Convey("etcdpasswd user list", func() { | |
stdout, stderr, err := RunOnRack0Boot("etcdpasswd", "user", "list") | |
code := ExitCode(err) | |
So(code, ShouldBeZeroValue) | |
So(stdout.String(), ShouldBeBlank) | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
Convey("grep bob /etc/passwd", func() { | |
stdout, stderr, err := RunOnRack0Boot("grep", testUser, "/etc/passwd") | |
code := ExitCode(err) | |
So(code, ShouldNotEqual, 0) | |
So(stdout.String(), ShouldBeBlank) | |
So(stderr.String(), ShouldBeBlank) | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment