Skip to content

Commit 7592a74

Browse files
committed
randomized subdomain, staging CA
1 parent aea6243 commit 7592a74

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

test/e2e/certificate_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ func TestCertificate(t *testing.T) {
4343
t.Skip("Skipping because CERT_DOMAIN is not set")
4444
}
4545

46+
// random subdomain
47+
certDomain = fmt.Sprintf("%s.%s", randomHex(4), certDomain)
48+
4649
certName := withSuffix("test-certificate-managed")
4750
certID, err := createCertificate(t, certName, "--type", "managed", "--domain", certDomain)
4851
require.NoError(t, err)
@@ -72,6 +75,12 @@ func runCertificateTestSuite(t *testing.T, certName string, certID int64, certTy
7275
require.NoError(t, err)
7376
assert.Equal(t, fmt.Sprintf("Label(s) baz added to certificate %d\n", certID), out)
7477
})
78+
79+
t.Run("HC-Staging-CA", func(t *testing.T) {
80+
out, err := runCommand(t, "certificate", "add-label", strconv.FormatInt(certID, 10), "HC-Use-Staging-CA=true")
81+
require.NoError(t, err)
82+
assert.Equal(t, fmt.Sprintf("Label(s) HC-Use-Staging-CA added to certificate %d\n", certID), out)
83+
})
7584
})
7685

7786
t.Run("update-name", func(t *testing.T) {
@@ -100,7 +109,7 @@ func runCertificateTestSuite(t *testing.T, certName string, certID int64, certTy
100109
).Newline().
101110
Lit(strconv.FormatInt(certID, 10)).Whitespace().
102111
Lit(certName).Whitespace().
103-
Lit("foo=bar").Whitespace().
112+
Lit("HC-Use-Staging-CA=true, foo=bar").Whitespace().
104113
Lit(string(certType)).Whitespace().
105114
UnixDate().Whitespace().
106115
UnixDate().Whitespace().
@@ -139,6 +148,7 @@ func runCertificateTestSuite(t *testing.T, certName string, certID int64, certTy
139148
Lit("Domain names:").Newline().
140149
Lit(" - ").Lit(domainName).Newline().
141150
Lit("Labels:").Newline().
151+
Lit(" HC-Use-Staging-CA:").Whitespace().Lit("true").Newline().
142152
Lit(" foo:").Whitespace().Lit("bar").Newline().
143153
Lit("Used By:").Newline().
144154
Lit(" Certificate unused").Newline().

test/e2e/e2e_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,15 @@ func runCommand(t *testing.T, args ...string) (string, error) {
5555
return buf.String(), err
5656
}
5757

58-
func withSuffix(s string) string {
59-
b := make([]byte, 4)
58+
func randomHex(n int) string {
59+
b := make([]byte, n)
6060
_, err := rand.Read(b)
6161
if err != nil {
6262
panic(err)
6363
}
64-
suffix := hex.EncodeToString(b)
65-
return fmt.Sprintf("%s-%s", s, suffix)
64+
return hex.EncodeToString(b)
65+
}
66+
67+
func withSuffix(s string) string {
68+
return fmt.Sprintf("%s-%s", s, randomHex(4))
6669
}

0 commit comments

Comments
 (0)