github.com/alloyci/alloy-runner@v1.0.1-0.20180222164613-925503ccafd6/shells/abstract_test.go (about) 1 package shells 2 3 import ( 4 "fmt" 5 "testing" 6 7 "gitlab.com/gitlab-org/gitlab-runner/common" 8 "gitlab.com/gitlab-org/gitlab-runner/helpers/tls" 9 "gitlab.com/gitlab-org/gitlab-runner/shells/mocks" 10 ) 11 12 func TestWriteGitSSLConfig(t *testing.T) { 13 gitlabURL := "https://example.com:3443" 14 runnerURL := gitlabURL + "/ci/" 15 16 shell := AbstractShell{} 17 build := &common.Build{ 18 Runner: &common.RunnerConfig{ 19 RunnerCredentials: common.RunnerCredentials{ 20 URL: runnerURL, 21 }, 22 }, 23 JobResponse: common.JobResponse{ 24 TLSAuthCert: "TLS_CERT", 25 TLSAuthKey: "TLS_KEY", 26 TLSCAChain: "CA_CHAIN", 27 }, 28 } 29 30 mockWriter := new(mocks.ShellWriter) 31 mockWriter.On("TmpFile", tls.VariableCAFile).Return(tls.VariableCAFile).Once() 32 mockWriter.On("TmpFile", tls.VariableCertFile).Return(tls.VariableCertFile).Once() 33 mockWriter.On("TmpFile", tls.VariableKeyFile).Return(tls.VariableKeyFile).Once() 34 35 mockWriter.On("Command", "git", "config", fmt.Sprintf("http.%s.%s", gitlabURL, "sslCAInfo"), tls.VariableCAFile).Once() 36 mockWriter.On("Command", "git", "config", fmt.Sprintf("http.%s.%s", gitlabURL, "sslCert"), tls.VariableCertFile).Once() 37 mockWriter.On("Command", "git", "config", fmt.Sprintf("http.%s.%s", gitlabURL, "sslKey"), tls.VariableKeyFile).Once() 38 39 shell.writeGitSSLConfig(mockWriter, build, nil) 40 41 mockWriter.AssertExpectations(t) 42 }