From 9df35356572e09dc2c0907113bf64479204e46a9 Mon Sep 17 00:00:00 2001 From: Vladimir Shushlin Date: Mon, 3 Jun 2019 11:22:03 +0000 Subject: Redirect unknown ACME challenges to the GitLab instance --- config_test.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 config_test.go (limited to 'config_test.go') diff --git a/config_test.go b/config_test.go new file mode 100644 index 00000000..3ec51c56 --- /dev/null +++ b/config_test.go @@ -0,0 +1,54 @@ +package main + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestGitLabServerFromFlags(t *testing.T) { + tests := []struct { + name string + gitLabServer string + gitLabAuthServer string + artifactsServer string + expected string + }{ + { + name: "When gitLabServer is set", + gitLabServer: "gitlabserver.com", + gitLabAuthServer: "authserver.com", + artifactsServer: "https://artifactsserver.com", + expected: "gitlabserver.com", + }, + { + name: "When auth server is set", + gitLabServer: "", + gitLabAuthServer: "authserver.com", + artifactsServer: "https://artifactsserver.com", + expected: "authserver.com", + }, + { + name: "When only artifacts server is set", + gitLabServer: "", + gitLabAuthServer: "", + artifactsServer: "https://artifactsserver.com", + expected: "artifactsserver.com", + }, + { + name: "When only artifacts server includes path", + gitLabServer: "", + gitLabAuthServer: "", + artifactsServer: "https://artifactsserver.com:8080/api/path", + expected: "artifactsserver.com", + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + gitLabServer = &test.gitLabServer + gitLabAuthServer = &test.gitLabAuthServer + artifactsServer = &test.artifactsServer + assert.Equal(t, test.expected, gitlabServerFromFlags()) + }) + } +} -- cgit v1.2.3