entitlementcard icon indicating copy to clipboard operation
entitlementcard copied to clipboard

1424: Add entitlementsId column in cards table

Open seluianova opened this issue 5 months ago • 0 comments

Short description

Create an entitlements_id column in the cards table to add a reference between cards and user entitlements

Proposed changes

  • add new entitlements_id column in the cards table
  • add a constraint - either entitlements_id or issuer_id must be not null in the cards table
  • revoke old cards by entitlements_id when issuing a new card with the same entitlements
  • adjust tests

Side effects

  • no?

Testing

  1. Import user entitlements via POST http://localhost:8000/users/import Include CSV file as a form-data:
regionKey,userHash,startDate,endDate,revoked
07111,"$argon2id$v=19$m=19456,t=2,p=1$57YPIKvU/XE9h7/JA0tZFT2TzpwBQfYAW6K+ojXBh5w",01.01.2024,01.01.2025,false
  1. Send a graphql request to create cards, check that the cards have been created and the entitlements_id column is populated
mutation CreateCardFromSelfService {
    createCardFromSelfService(
        project: "koblenz.sozialpass.app"
        encodedCardInfo: "Cg1LYXJsYSBLb2JsZW56GhIKAghfEgQI6r4BMgYKBDEyM0s="
        generateStaticCode: true
    ) {
        dynamicActivationCode {
            cardInfoHashBase64
            codeBase64
        }
        staticVerificationCode {
            cardInfoHashBase64
            codeBase64
        }
    }
}
  1. Send graphql request to create cards again, check that the new cards are created and old cards are updated to revoked=true

Resolved issues

Fixes: #1424

seluianova avatar Sep 11 '24 13:09 seluianova