fix: ensure test cleanup

This commit is contained in:
Jahziel Villasana-Espinoza 2024-06-04 09:45:53 -04:00
parent 3dc65d7432
commit 945eb778a6

View file

@ -931,6 +931,7 @@ func (s *integrationMDMTestSuite) TestGetMDMCSR() {
// Validate errors if no private key is set
testSetEmptyPrivateKey = true
t.Cleanup(func() { testSetEmptyPrivateKey = false })
s.uploadAPNSCert([]byte("-----BEGIN CERTIFICATE-----\nZm9vCg==\n-----END CERTIFICATE-----"), http.StatusInternalServerError, "Couldn't upload APNs certificate. Missing required private key. Learn how to configure the private key here: https://fleetdm.com/learn-more-about/fleet-server-private-key")
r := s.Do("GET", "/api/latest/fleet/mdm/apple/request_csr", getMDMAppleCSRRequest{}, http.StatusInternalServerError)
@ -8677,6 +8678,7 @@ func (s *integrationMDMTestSuite) TestABMAssetManagement() {
// Validate error when server private key not set
testSetEmptyPrivateKey = true
t.Cleanup(func() { testSetEmptyPrivateKey = false })
r := s.Do("GET", "/api/latest/fleet/mdm/apple/abm_public_key", generateABMKeyPairResponse{}, http.StatusInternalServerError)
require.Contains(t, extractServerErrorText(r.Body), "Couldn't download public key. Missing required private key. Learn how to configure the private key here: https://fleetdm.com/learn-more-about/fleet-server-private-key")