(t *testing.T)
| 63 | } |
| 64 | |
| 65 | func 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 | |
| 90 | func TestIsAllowedCertificateURL(t *testing.T) { |
| 91 | t.Parallel() |
nothing calls this directly
no test coverage detected