Address greptile comments

This commit is contained in:
Carlos Monastyrski
2025-11-22 01:14:10 -03:00
parent 0f32784834
commit c0060c1d22
5 changed files with 5 additions and 12 deletions
@@ -24,8 +24,4 @@ export async function down(knex: Knex): Promise<void> {
t.dropColumn("issuerType"); t.dropColumn("issuerType");
}); });
} }
await knex.schema.alterTable(TableName.PkiCertificateProfile, (t) => {
t.uuid("caId").notNullable().alter();
});
} }
@@ -415,9 +415,7 @@ export const certificateProfileServiceFactory = ({
validateIssuerTypeConstraints(finalIssuerType, finalEnrollmentType, finalCaId ?? null, existingProfile.caId); validateIssuerTypeConstraints(finalIssuerType, finalEnrollmentType, finalCaId ?? null, existingProfile.caId);
const updatedData = const updatedData =
finalIssuerType === IssuerType.SELF_SIGNED && existingProfile.caId && data.issuerType === IssuerType.SELF_SIGNED finalIssuerType === IssuerType.SELF_SIGNED && existingProfile.caId ? { ...data, caId: null } : data;
? { ...data, caId: null }
: data;
const { estConfig, apiConfig, ...profileUpdateData } = updatedData; const { estConfig, apiConfig, ...profileUpdateData } = updatedData;
@@ -1792,7 +1792,7 @@ describe("CertificateV3Service", () => {
certificateId: "cert-123", certificateId: "cert-123",
...mockActor ...mockActor
}) })
).rejects.toThrow("Only certificates issued from a profile or self-signed certificates can be renewed"); ).rejects.toThrow("Only certificates issued from a profile can be renewed");
}); });
it("should reject renewal if certificate was issued from CSR (external private key)", async () => { it("should reject renewal if certificate was issued from CSR (external private key)", async () => {
@@ -1191,10 +1191,9 @@ export const certificateV3ServiceFactory = ({
throw new NotFoundError({ message: "Certificate not found" }); throw new NotFoundError({ message: "Certificate not found" });
} }
const isSelfSigned = !originalCert.profileId && !originalCert.caId && originalCert.certificateTemplateId === null; if (!originalCert.profileId) {
if (!originalCert.profileId && !originalCert.caId && !isSelfSigned) {
throw new ForbiddenRequestError({ throw new ForbiddenRequestError({
message: "Only certificates issued from a profile or self-signed certificates can be renewed" message: "Only certificates issued from a profile can be renewed"
}); });
} }
@@ -49,7 +49,7 @@ export const ProfileRow = ({
}: Props) => { }: Props) => {
const { permission } = useProjectPermission(); const { permission } = useProjectPermission();
const { data: caData } = useGetCaById(profile.caId || ""); const { data: caData } = useGetCaById(profile.caId ?? "");
const { popUp, handlePopUpToggle } = usePopUp(["issueCertificate"] as const); const { popUp, handlePopUpToggle } = usePopUp(["issueCertificate"] as const);