aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/target_test.go23
1 files changed, 19 insertions, 4 deletions
diff --git a/test/target_test.go b/test/target_test.go
index 0fcd94d..50483ff 100644
--- a/test/target_test.go
+++ b/test/target_test.go
@@ -234,10 +234,12 @@ func TestTarget(t *testing.T) {
chTerm <- ev
})
- /*open terminals*/
- PostTerms(t, "open", chTermEvt)
-
/*just for the first term*/
+ var terms []xsapiv1.TerminalConfig
+ var term xsapiv1.TerminalConfig
+ assert.Nil(t, HTTPCli.Get("/targets/"+listID[0]+"/terminals", &terms))
+ assert.Nil(t, HTTPCli.Post("/targets/"+listID[0]+"/terminals/"+terms[0].ID+"/open", terms[0], &term))
+ <-chTermEvt //waiting for event terminalStateChange
termOut := <-chTerm //waiting for terminalOutMsg
flushChannelTerm(chTerm, 50) //flushing all terminalOutMsg
stdoutMsg := string(termOut.Stdout)
@@ -247,7 +249,20 @@ func TestTarget(t *testing.T) {
t.Fatalf("%vcopy your pub key in authorized_keys\ncat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys", stdoutMsg)
}
assert.True(t, strings.Contains(stdoutMsg, "Last login")) //first terminal msg should be Last Login
- t.Logf("terminal is open, console msg is %v", stdoutMsg)
+ assert.Nil(t, HTTPCli.Post("/targets/"+listID[0]+"/terminals/"+terms[0].ID+"/close", terms[0], &term))
+ <-chTermEvt //waiting for event terminalStateChange
+
+ /*open terminals*/
+ PostTerms(t, "open", chTermEvt)
+ termOut = <-chTerm //waiting for terminalOutMsg
+ flushChannelTerm(chTerm, 50) //flushing all terminalOutMsg
+ stdoutMsg = string(termOut.Stdout)
+ if strings.Contains(stdoutMsg, "Connection refused") {
+ t.Fatalf("%vYou may have to launch ssh server", stdoutMsg)
+ } else if strings.Contains(stdoutMsg, "password") {
+ t.Fatalf("%vcopy your pub key in authorized_keys\ncat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys", stdoutMsg)
+ }
+ assert.True(t, strings.Contains(stdoutMsg, "Last login")) //first terminal msg should be Last Login
/*create toto file through terminals*/
rootCfgDir := os.Getenv(envRootCfgDir)