MCPcopy Create free account
hub / github.com/coder/coder / TestExpiresSoon

Function TestExpiresSoon

coderd/azureidentity/azureidentity_test.go:65–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

63}
64
65func TestExpiresSoon(t *testing.T) {
66 t.Parallel()
67 // TODO (@kylecarbs): It's unknown why Microsoft does not have new certificates live...
68 // The certificate is automatically fetched if it's not found in our database,
69 // so in a worst-case scenario expired certificates will only impact 100% airgapped users.
70 t.Skip()
71 const threshold = 1
72
73 certs, err := azureidentity.ParseCertificates()
74 require.NoError(t, err)
75
76 for _, cert := range certs {
77 expiresSoon := cert.NotAfter.Before(time.Now().AddDate(0, threshold, 0))
78 if expiresSoon {
79 t.Errorf("certificate expires within %d months %s: %s", threshold, cert.NotAfter, cert.Subject.CommonName)
80 } else {
81 url := "no issuing url"
82 if len(cert.IssuingCertificateURL) > 0 {
83 url = cert.IssuingCertificateURL[0]
84 }
85 t.Logf("certificate %q doesn't expire for a while (%s)", cert.Subject.CommonName, url)
86 }
87 }
88}
89
90func TestIsAllowedCertificateURL(t *testing.T) {
91 t.Parallel()

Callers

nothing calls this directly

Calls 4

ParseCertificatesFunction · 0.92
SkipMethod · 0.80
LogfMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected