From 4192072863ac0997b0c3cb4131ea913e6f85f83e Mon Sep 17 00:00:00 2001 From: Clément Bénier Date: Tue, 21 Aug 2018 11:06:36 +0200 Subject: test target: open 1 terminal for connection errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit before opening all terminals, open just one to check there is no ssh connection problems Change-Id: I700a00264a96480ac4656be6338e2d728f509627 Signed-off-by: Clément Bénier --- test/target_test.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'test') 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) -- cgit 1.2.3-korg