fleet/frontend/__mocks__/certificatesMock.ts
jacobshandling ca2fc6030f
Create, list, delete Android certificates from the UI (#37314)
**Related issue:** Resolves #36689 

<img width="1840" height="1196" alt="Screenshot 2025-12-15 at 5 08
02 PM"
src="https://github.com/user-attachments/assets/4f491c80-403f-4188-8cab-552e997c6e9c"
/>
<img width="1840" height="1196" alt="Screenshot 2025-12-15 at 5 09
18 PM"
src="https://github.com/user-attachments/assets/b6e4d9ad-40c1-45c3-8b77-e14d17a2bc7e"
/>
<img width="1840" height="1196" alt="Screenshot 2025-12-15 at 5 09
22 PM"
src="https://github.com/user-attachments/assets/661beee2-3ee2-4269-ab0b-ca070c1a40b8"
/>




If some of the following don't apply, delete the relevant line.

- [x] Changes file added for user-visible changes in `changes/`
- [x] Added/updated automated tests
- [x] QA'd all new/changed functionality manually

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **New Features**
* Added comprehensive Android certificate management in OS Settings with
create, list, and delete operations
* Integrated certificate management with premium tier gating and MDM
enablement checks
  * Supports team-scoped certificates with pagination controls
* Includes validation for certificate names and certificate authority
selection

* **Refactor**
* Generalized heading component to support multiple entity types beyond
configuration profiles

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-12-16 15:39:07 -08:00

80 lines
2.2 KiB
TypeScript

import {
ICertificateAuthorityPartial,
IHostCertificate,
} from "interfaces/certificates";
import { ICertificate } from "services/entities/certificates";
import { IGetHostCertificatesResponse } from "services/entities/hosts";
const DEFAULT_HOST_CERTIFICATE_MOCK: IHostCertificate = {
id: 1,
not_valid_after: "2021-08-19T02:02:17Z",
not_valid_before: "2021-08-19T02:02:17Z",
certificate_authority: true,
common_name: "Test Cert",
key_algorithm: "rsaEncryption",
key_strength: 2048,
key_usage: "CRL Sign, Key Cert Sign",
serial: "123",
signing_algorithm: "sha256WithRSAEncryption",
subject: {
country: "US",
organization: "Test Inc.",
organizational_unit: "Test Inc.",
common_name: "Test Biz",
},
issuer: {
country: "US",
organization: "Test Inc.",
organizational_unit: "Test Inc.",
common_name: "Test Biz",
},
source: "system",
username: "",
};
export const createMockHostCertificate = (
overrides?: Partial<IHostCertificate>
): IHostCertificate => {
return { ...DEFAULT_HOST_CERTIFICATE_MOCK, ...overrides };
};
const DEFAULT_HOST_CERTIFICATES_RESPONSE_MOCK: IGetHostCertificatesResponse = {
certificates: [createMockHostCertificate()],
meta: {
has_next_results: false,
has_previous_results: false,
},
count: 1,
};
export const createMockGetHostCertificatesResponse = (
overrides?: Partial<IGetHostCertificatesResponse>
): IGetHostCertificatesResponse => {
return { ...DEFAULT_HOST_CERTIFICATES_RESPONSE_MOCK, ...overrides };
};
const DEFAULT_CERT_AUTHORITY_PARTIAL_MOCK: ICertificateAuthorityPartial = {
id: 1,
name: "Test CA",
type: "digicert",
};
export const createMockCertificateAuthorityPartial = (
overrides?: Partial<ICertificateAuthorityPartial>
): ICertificateAuthorityPartial => {
return { ...DEFAULT_CERT_AUTHORITY_PARTIAL_MOCK, ...overrides };
};
const DEFAULT_ANDROID_CERT_MOCK: ICertificate = {
id: 1,
name: "Test Android Certificate",
certificate_authority_id: 1,
certificate_authority_name: "Test CA",
created_at: "2021-08-19T02:02:17Z",
};
export const createMockAndroidCert = (
overrides?: Partial<ICertificate>
): ICertificate => {
return { ...DEFAULT_ANDROID_CERT_MOCK, ...overrides };
};