update error message on os settings error details on host details (#27441)

For #27440

Updates showing the profile error message in os settings error cell to
show on a different error message from the API.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Added/updated automated tests
- [x] Manual QA for all new/changed functionality
This commit is contained in:
Gabriel Hernandez 2025-03-25 14:01:54 +00:00 committed by GitHub
parent 4b5cb913b7
commit 5c56796403
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 16 deletions

View file

@ -108,7 +108,7 @@ describe("OSSettingsErrorCell", () => {
hostId={1}
profile={createMockHostMdmProfile({
status: "failed",
detail: `Fleet couldnt populate $FLEET_VAR_CUSTOM_SCEP_URL_SCEP_WIFI because SCEP_WIFI certificate authority doesnt exist.`,
detail: `Fleet couldn't populate $FLEET_VAR_CUSTOM_SCEP_URL_SCEP_WIFI because SCEP_WIFI certificate authority doesn't exist.`,
})}
/>
);
@ -121,14 +121,14 @@ describe("OSSettingsErrorCell", () => {
).toBeInTheDocument();
});
it("renders a formatted tooltip when the error message matches digicert guid patern", () => {
it("renders a formatted tooltip when the error message matches digicert profile id error", () => {
render(
<OSSettingsErrorCell
canResendProfiles
hostId={1}
profile={createMockHostMdmProfile({
status: "failed",
detail: `Couldnt get certificate from DigiCert. The "profile_id" configured in DIGICERT_WIFI certificate authority doesnt exist.`,
detail: `Couldn't get certificate from DigiCert for WIFI_CERTIFICATE. unexpected DigiCert status code for POST request: 410, errors: Profile with id {test-id} was deleted`,
})}
/>
);
@ -137,7 +137,28 @@ describe("OSSettingsErrorCell", () => {
screen.getByText("Settings > Integrations > Certificates")
).toBeInTheDocument();
expect(screen.getByText(/correct it and resend/)).toBeInTheDocument();
expect(screen.getByText("DIGICERT_WIFI")).toBeInTheDocument();
expect(screen.getByText("WIFI_CERTIFICATE")).toBeInTheDocument();
expect(screen.getByText("Profile GUID")).toBeInTheDocument();
});
it("renders a formatted tooltip when the error message matches digicert deleted profile error", () => {
render(
<OSSettingsErrorCell
canResendProfiles
hostId={1}
profile={createMockHostMdmProfile({
status: "failed",
detail: `Couldn't get certificate from DigiCert for WIFI_CERTIFICATE. unexpected DigiCert status code for POST request: 400, errors: Enrollment creation and Certificate issuance/renewal for deleted or suspended Profile are not supported.
Please contact system Administrator.`,
})}
/>
);
expect(
screen.getByText("Settings > Integrations > Certificates")
).toBeInTheDocument();
expect(screen.getByText(/correct it and resend/)).toBeInTheDocument();
expect(screen.getByText("WIFI_CERTIFICATE")).toBeInTheDocument();
expect(screen.getByText("Profile GUID")).toBeInTheDocument();
});

View file

@ -50,6 +50,12 @@ const RefetchButton = ({ isFetching, onClick }: IRefetchButtonProps) => {
* the detail does not match any of the expected patterns.
*/
const formatDetailCertificateError = (detail: IHostMdmProfile["detail"]) => {
const formattedCertificatesPath = (
<b>
Settings {">"} Integrations {">"} Certificates
</b>
);
const matchTokenErr = detail.match(
/get certificate from (?:DigiCert|Digicert|digicert).*token configured in (?<ca>.*) certificate authority is invalid/
);
@ -58,28 +64,28 @@ const formatDetailCertificateError = (detail: IHostMdmProfile["detail"]) => {
<>
Couldn&apos;t get certificate from DigiCert. The <b>API token</b>{" "}
configured in <b>{matchTokenErr.groups.ca}</b> certificate authority is
invalid. Please go to{" "}
<b>
Settings {">"} Integrations {">"} Certificates
</b>
, correct it and resend.
invalid. Please go to {formattedCertificatesPath}, correct it and
resend.
</>
);
}
const matchProfileIdErr = detail.match(
/get certificate from (?:DigiCert|Digicert|digicert).*profile_id.*configured in (?<ca>.*) certificate authority does(?:n.t| not) exist/
/get certificate from (?:DigiCert|Digicert|digicert) for (?<ca>.*)\..*POST request: 410.*Profile with id.*was deleted/
);
if (matchProfileIdErr?.groups) {
const matchDeletedProfileErr = detail.match(
/get certificate from (?:DigiCert|Digicert|digicert) for (?<ca>.*)\..*POST request: 400.*deleted or suspended Profile/
);
if (matchProfileIdErr?.groups || matchDeletedProfileErr?.groups) {
return (
<>
Couldn&apos;t get certificate from DigiCert. The <b>Profile GUID</b>{" "}
configured in <b>{matchProfileIdErr.groups.ca}</b> certificate authority
doesn&apos;t exist. Please go to{" "}
configured in{" "}
<b>
Settings {">"} Integrations {">"} Certificates
</b>
, correct it and resend.
{matchProfileIdErr?.groups?.ca || matchDeletedProfileErr?.groups?.ca}
</b>{" "}
certificate authority doesn&apos;t exist. Please go to{" "}
{formattedCertificatesPath}, correct it and resend.
</>
);
}