@@ -234,3 +234,70 @@ async def test_create_credential_definition(
234
234
# There should be two revocation registries, assert at least one exists
235
235
# one being used to issue credentials against and once full with to the next one
236
236
assert len (revocation_registries ) >= 1
237
+
238
+
239
+ @pytest .mark .anyio
240
+ @pytest .mark .parametrize ("support_revocation" , [False , True ])
241
+ @pytest .mark .xdist_group (name = "issuer_test_group" )
242
+ async def test_create_anoncreds_credential_definition (
243
+ anoncreds_schema_definition : CredentialSchema ,
244
+ faber_anoncreds_acapy_client : AcaPyClient ,
245
+ faber_anoncreds_client : RichAsyncClient ,
246
+ support_revocation : bool ,
247
+ ):
248
+ schema_id = anoncreds_schema_definition .id
249
+ tag = random_string (5 )
250
+ credential_definition = CreateCredentialDefinition (
251
+ schema_id = schema_id ,
252
+ tag = tag ,
253
+ support_revocation = support_revocation ,
254
+ )
255
+
256
+ auth = acapy_auth_verified (
257
+ acapy_auth_from_header (faber_anoncreds_client .headers ["x-api-key" ])
258
+ )
259
+
260
+ result = (
261
+ await definitions .create_credential_definition (
262
+ credential_definition = credential_definition , auth = auth
263
+ )
264
+ ).model_dump ()
265
+
266
+ faber_public_did = await get_public_did (faber_anoncreds_acapy_client )
267
+ schema = await faber_anoncreds_acapy_client .anoncreds_schemas .get_schema (
268
+ schema_id = schema_id
269
+ )
270
+
271
+ assert_that (result ).has_id (
272
+ f"{ faber_public_did .did } :3:CL:{ schema .schema_metadata ['seqNo' ]} :{ tag } "
273
+ )
274
+ assert_that (result ).has_tag (tag )
275
+ assert_that (result ).has_schema_id (schema_id )
276
+
277
+ cred_def_id = result ["id" ]
278
+ get_cred_def_result = (
279
+ await definitions .get_credential_definition_by_id (cred_def_id , auth )
280
+ ).model_dump ()
281
+
282
+ assert_that (get_cred_def_result ).has_tag (tag )
283
+ assert_that (get_cred_def_result ).has_schema_id (schema_id )
284
+
285
+ if support_revocation :
286
+ # Assert that revocation registry was created
287
+ rev_reg_result = await faber_anoncreds_acapy_client .anoncreds_revocation .get_active_revocation_registry (
288
+ cred_def_id
289
+ )
290
+ issuer_rev_reg_record = rev_reg_result .result
291
+ assert issuer_rev_reg_record
292
+ assert cred_def_id == issuer_rev_reg_record .cred_def_id
293
+ assert issuer_rev_reg_record .issuer_did == faber_public_did .did
294
+
295
+ revocation_registries = (
296
+ await faber_anoncreds_acapy_client .anoncreds_revocation .get_revocation_registries (
297
+ cred_def_id = cred_def_id
298
+ )
299
+ ).rev_reg_ids
300
+
301
+ # There should be two revocation registries, assert at least one exists
302
+ # one being used to issue credentials against and once full with to the next one
303
+ assert len (revocation_registries ) >= 1
0 commit comments