mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 01:18:42 +00:00
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:
parent
4b5cb913b7
commit
5c56796403
2 changed files with 43 additions and 16 deletions
|
|
@ -108,7 +108,7 @@ describe("OSSettingsErrorCell", () => {
|
|||
hostId={1}
|
||||
profile={createMockHostMdmProfile({
|
||||
status: "failed",
|
||||
detail: `Fleet couldn’t populate $FLEET_VAR_CUSTOM_SCEP_URL_SCEP_WIFI because SCEP_WIFI certificate authority doesn’t 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: `Couldn’t get certificate from DigiCert. The "profile_id" configured in DIGICERT_WIFI certificate authority doesn’t 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();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'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't get certificate from DigiCert. The <b>Profile GUID</b>{" "}
|
||||
configured in <b>{matchProfileIdErr.groups.ca}</b> certificate authority
|
||||
doesn'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't exist. Please go to{" "}
|
||||
{formattedCertificatesPath}, correct it and resend.
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue