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

View File

@@ -24,8 +24,4 @@ export async function down(knex: Knex): Promise<void> {
t.dropColumn("issuerType");
});
}
await knex.schema.alterTable(TableName.PkiCertificateProfile, (t) => {
t.uuid("caId").notNullable().alter();
});
}

View File

@@ -415,9 +415,7 @@ export const certificateProfileServiceFactory = ({
validateIssuerTypeConstraints(finalIssuerType, finalEnrollmentType, finalCaId ?? null, existingProfile.caId);
const updatedData =
finalIssuerType === IssuerType.SELF_SIGNED && existingProfile.caId && data.issuerType === IssuerType.SELF_SIGNED
? { ...data, caId: null }
: data;
finalIssuerType === IssuerType.SELF_SIGNED && existingProfile.caId ? { ...data, caId: null } : data;
const { estConfig, apiConfig, ...profileUpdateData } = updatedData;

View File

@@ -1792,7 +1792,7 @@ describe("CertificateV3Service", () => {
certificateId: "cert-123",
...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 () => {

View File

@@ -1191,10 +1191,9 @@ export const certificateV3ServiceFactory = ({
throw new NotFoundError({ message: "Certificate not found" });
}
const isSelfSigned = !originalCert.profileId && !originalCert.caId && originalCert.certificateTemplateId === null;
if (!originalCert.profileId && !originalCert.caId && !isSelfSigned) {
if (!originalCert.profileId) {
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"
});
}

View File

@@ -49,7 +49,7 @@ export const ProfileRow = ({
}: Props) => {
const { permission } = useProjectPermission();
const { data: caData } = useGetCaById(profile.caId || "");
const { data: caData } = useGetCaById(profile.caId ?? "");
const { popUp, handlePopUpToggle } = usePopUp(["issueCertificate"] as const);