|
|
@@ -15,20 +15,20 @@ func TestCLI_User_Add(t *testing.T) {
|
|
|
s, conf, port := newTestServerWithAuth(t)
|
|
|
defer test.StopServer(t, s, port)
|
|
|
|
|
|
- app, stdin, _, stderr := newTestApp()
|
|
|
+ app, stdin, stdout, _ := newTestApp()
|
|
|
stdin.WriteString("mypass\nmypass")
|
|
|
require.Nil(t, runUserCommand(app, conf, "add", "phil"))
|
|
|
- require.Contains(t, stderr.String(), "user phil added with role user")
|
|
|
+ require.Contains(t, stdout.String(), "user phil added with role user")
|
|
|
}
|
|
|
|
|
|
func TestCLI_User_Add_Exists(t *testing.T) {
|
|
|
s, conf, port := newTestServerWithAuth(t)
|
|
|
defer test.StopServer(t, s, port)
|
|
|
|
|
|
- app, stdin, _, stderr := newTestApp()
|
|
|
+ app, stdin, stdout, _ := newTestApp()
|
|
|
stdin.WriteString("mypass\nmypass")
|
|
|
require.Nil(t, runUserCommand(app, conf, "add", "phil"))
|
|
|
- require.Contains(t, stderr.String(), "user phil added with role user")
|
|
|
+ require.Contains(t, stdout.String(), "user phil added with role user")
|
|
|
|
|
|
app, stdin, _, _ = newTestApp()
|
|
|
stdin.WriteString("mypass\nmypass")
|
|
|
@@ -41,10 +41,10 @@ func TestCLI_User_Add_Admin(t *testing.T) {
|
|
|
s, conf, port := newTestServerWithAuth(t)
|
|
|
defer test.StopServer(t, s, port)
|
|
|
|
|
|
- app, stdin, _, stderr := newTestApp()
|
|
|
+ app, stdin, stdout, _ := newTestApp()
|
|
|
stdin.WriteString("mypass\nmypass")
|
|
|
require.Nil(t, runUserCommand(app, conf, "add", "--role=admin", "phil"))
|
|
|
- require.Contains(t, stderr.String(), "user phil added with role admin")
|
|
|
+ require.Contains(t, stdout.String(), "user phil added with role admin")
|
|
|
}
|
|
|
|
|
|
func TestCLI_User_Add_Password_Mismatch(t *testing.T) {
|
|
|
@@ -63,16 +63,16 @@ func TestCLI_User_ChangePass(t *testing.T) {
|
|
|
defer test.StopServer(t, s, port)
|
|
|
|
|
|
// Add user
|
|
|
- app, stdin, _, stderr := newTestApp()
|
|
|
+ app, stdin, stdout, _ := newTestApp()
|
|
|
stdin.WriteString("mypass\nmypass")
|
|
|
require.Nil(t, runUserCommand(app, conf, "add", "phil"))
|
|
|
- require.Contains(t, stderr.String(), "user phil added with role user")
|
|
|
+ require.Contains(t, stdout.String(), "user phil added with role user")
|
|
|
|
|
|
// Change pass
|
|
|
- app, stdin, _, stderr = newTestApp()
|
|
|
+ app, stdin, stdout, _ = newTestApp()
|
|
|
stdin.WriteString("newpass\nnewpass")
|
|
|
require.Nil(t, runUserCommand(app, conf, "change-pass", "phil"))
|
|
|
- require.Contains(t, stderr.String(), "changed password for user phil")
|
|
|
+ require.Contains(t, stdout.String(), "changed password for user phil")
|
|
|
}
|
|
|
|
|
|
func TestCLI_User_ChangeRole(t *testing.T) {
|
|
|
@@ -80,15 +80,15 @@ func TestCLI_User_ChangeRole(t *testing.T) {
|
|
|
defer test.StopServer(t, s, port)
|
|
|
|
|
|
// Add user
|
|
|
- app, stdin, _, stderr := newTestApp()
|
|
|
+ app, stdin, stdout, _ := newTestApp()
|
|
|
stdin.WriteString("mypass\nmypass")
|
|
|
require.Nil(t, runUserCommand(app, conf, "add", "phil"))
|
|
|
- require.Contains(t, stderr.String(), "user phil added with role user")
|
|
|
+ require.Contains(t, stdout.String(), "user phil added with role user")
|
|
|
|
|
|
// Change role
|
|
|
- app, _, _, stderr = newTestApp()
|
|
|
+ app, _, stdout, _ = newTestApp()
|
|
|
require.Nil(t, runUserCommand(app, conf, "change-role", "phil", "admin"))
|
|
|
- require.Contains(t, stderr.String(), "changed role for user phil to admin")
|
|
|
+ require.Contains(t, stdout.String(), "changed role for user phil to admin")
|
|
|
}
|
|
|
|
|
|
func TestCLI_User_Delete(t *testing.T) {
|
|
|
@@ -96,15 +96,15 @@ func TestCLI_User_Delete(t *testing.T) {
|
|
|
defer test.StopServer(t, s, port)
|
|
|
|
|
|
// Add user
|
|
|
- app, stdin, _, stderr := newTestApp()
|
|
|
+ app, stdin, stdout, _ := newTestApp()
|
|
|
stdin.WriteString("mypass\nmypass")
|
|
|
require.Nil(t, runUserCommand(app, conf, "add", "phil"))
|
|
|
- require.Contains(t, stderr.String(), "user phil added with role user")
|
|
|
+ require.Contains(t, stdout.String(), "user phil added with role user")
|
|
|
|
|
|
// Delete user
|
|
|
- app, _, _, stderr = newTestApp()
|
|
|
+ app, _, stdout, _ = newTestApp()
|
|
|
require.Nil(t, runUserCommand(app, conf, "del", "phil"))
|
|
|
- require.Contains(t, stderr.String(), "user phil removed")
|
|
|
+ require.Contains(t, stdout.String(), "user phil removed")
|
|
|
|
|
|
// Delete user again (does not exist)
|
|
|
app, _, _, _ = newTestApp()
|