Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Certificate Rotation Automation

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Certificate Rotation Automation. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Can you write a function to automate the rotation and validation of expired security certificates across multiple cloud environments?

Implement rotate_and_validate(certificates, now, rotation_window, policies). Return actions only for certificates expiring at or before now + rotation_window, sorted by cloud, environment, service, and certificate ID. A replacement is valid when its ID is new and unique, it references the original certificate, matches cloud, environment, and service, expires later, and satisfies that cloud's issuer and key-type policy. Return rotated or blocked with a specific reason.

Constraints

  • 1 <= len(certificates) <= 500
  • Each certificate has unique id, cloud, environment, service, and integer expires_at fields
  • Each replacement has id, replaces, cloud, environment, service, expires_at, issuer, and key_type fields when present
  • 0 <= rotation_window <= 10^9
  • Each cloud policy contains issuers and key_types arrays
  • Return one action for every certificate with expires_at <= now + rotation_window

Function Signature

def rotate_and_validate(certificates, now, rotation_window, policies):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output