github.com/hyperledger/aries-framework-go@v0.3.2/pkg/doc/cm/credentialapplication_test.go (about) 1 /* 2 Copyright SecureKey Technologies Inc. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package cm_test 8 9 import ( 10 _ "embed" 11 "encoding/json" 12 "reflect" 13 "testing" 14 15 "github.com/stretchr/testify/require" 16 17 "github.com/hyperledger/aries-framework-go/pkg/doc/cm" 18 "github.com/hyperledger/aries-framework-go/pkg/doc/presexch" 19 "github.com/hyperledger/aries-framework-go/pkg/doc/verifiable" 20 "github.com/hyperledger/aries-framework-go/pkg/internal/ldtestutil" 21 ) 22 23 const unknownFormatName = "SomeUnknownFormat" 24 25 // Note that the term "Credential Application" can refer to two different, but related, concepts. See the 26 // documentation above the cm.CredentialApplication type definition for more information. 27 28 // Sample Credential Applications for a university degree. 29 // Here, "Credential Application" refers to the "credential_application" object that gets embedded within a larger 30 // envelope. 31 var ( 32 //go:embed testdata/credential_application_university_degree.json 33 credentialApplicationUniversityDegree []byte //nolint:gochecknoglobals 34 //go:embed testdata/credential_application_university_degree_with_format.json 35 credentialApplicationUniversityDegreeWithFormat []byte //nolint:gochecknoglobals 36 ) 37 38 // Sample "minimal" Verifiable Presentations. These are VPs that were created by a call to verifiable.NewPresentation() 39 // with no arguments/options, which is how the cm.PresentCredentialApplication method generates a VP if the 40 // WithExistingPresentationForPresentCredentialApplication option is not used. Additional data 41 // (like Credential Application and Credential Submission) was then added to it. 42 var ( 43 //go:embed testdata/VP_minimal_with_credential_application.json 44 vpMinimalWithCredentialApplication []byte //nolint:gochecknoglobals 45 //go:embed testdata/VP_minimal_with_credential_application_and_presentation_submission.json 46 vpMinimalWithCredentialApplicationAndPresentationSubmission []byte //nolint:gochecknoglobals 47 //go:embed testdata/VP_minimal_with_credential_application_and_presentation_submission_and_format.json 48 vpMinimalWithCredentialApplicationAndPresentationSubmissionAndFormat []byte //nolint:gochecknoglobals 49 ) 50 51 // Sample Verifiable Presentations that contain a PR card VC. 52 var ( 53 //go:embed testdata/VP_with_PR_Card_VC.json 54 vpWithPRCardVC []byte //nolint:gochecknoglobals 55 //go:embed testdata/VP_with_PR_card_VC_and_credential_application.json 56 vpWithPRCardVCAndCredentialApplication []byte //nolint:gochecknoglobals 57 //go:embed testdata/VP_with_PR_card_VC_and_credential_application_and_presentation_submission.json 58 vpWithPRCardVCAndCredentialApplicationAndPresentationSubmission []byte //nolint:gochecknoglobals 59 //go:embed testdata/VP_with_PR_card_VC_and_credential_application_and_presentation_submission_and_format.json 60 vpWithPRCardVCAndCredentialApplicationAndPresentationSubmissionAndFormat []byte //nolint:gochecknoglobals 61 //go:embed testdata/VP_with_PR_Card_VC_using_presentation_exchange_context.json 62 vpWithPRCardVCUsingPresentationExchangeContext []byte //nolint:gochecknoglobals 63 ) 64 65 // Sample Credential Application attachment. 66 //go:embed testdata/credential_application_presentation_drivers_license.json 67 var credentialApplicationDriversLicenseVP []byte //nolint:gochecknoglobals 68 69 func TestUnmarshalAndValidateAgainstCredentialManifest(t *testing.T) { 70 t.Run("Success", func(t *testing.T) { 71 credentialManifest := makeCredentialManifestFromBytes(t, credentialManifestUniversityDegree) 72 73 credentialApplication, err := cm.UnmarshalAndValidateAgainstCredentialManifest( 74 credentialApplicationUniversityDegree, &credentialManifest) 75 require.NoError(t, err) 76 require.Equal(t, "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", credentialApplication.ID) 77 }) 78 t.Run("Failure during validation", func(t *testing.T) { 79 credentialManifest := makeCredentialManifestFromBytes(t, credentialManifestUniversityDegreeWithFormat) 80 81 _, err := cm.UnmarshalAndValidateAgainstCredentialManifest( 82 credentialApplicationUniversityDegree, &credentialManifest) 83 require.EqualError(t, err, "invalid format for the given Credential Manifest: the Credential "+ 84 "Manifest specifies a format but the Credential Application does not") 85 }) 86 } 87 88 func TestValidateCredentialApplication(t *testing.T) { 89 loader, err := ldtestutil.DocumentLoader() 90 require.NoError(t, err) 91 92 t.Run("Success", func(t *testing.T) { 93 manifest := makeCredentialManifestFromBytes(t, 94 credentialManifestDriversLicenseWithPresentationDefinitionAndFormat) 95 96 application, err := verifiable.ParsePresentation(credentialApplicationDriversLicenseVP, 97 verifiable.WithPresDisabledProofCheck(), 98 verifiable.WithPresJSONLDDocumentLoader(loader)) 99 require.NoError(t, err) 100 require.NotEmpty(t, application) 101 102 err = cm.ValidateCredentialApplication(application, &manifest, loader, 103 presexch.WithCredentialOptions(verifiable.WithJSONLDDocumentLoader(loader), 104 verifiable.WithDisabledProofCheck())) 105 require.NoError(t, err) 106 107 manifest.PresentationDefinition = nil 108 err = cm.ValidateCredentialApplication(application, &manifest, loader, 109 presexch.WithCredentialOptions(verifiable.WithJSONLDDocumentLoader(loader), 110 verifiable.WithDisabledProofCheck())) 111 require.NoError(t, err) 112 }) 113 114 t.Run("failures", func(t *testing.T) { 115 manifest := makeCredentialManifestFromBytes(t, 116 credentialManifestDriversLicenseWithPresentationDefinitionAndFormat) 117 118 application, err := verifiable.ParsePresentation(credentialApplicationDriversLicenseVP, 119 verifiable.WithPresDisabledProofCheck(), 120 verifiable.WithPresJSONLDDocumentLoader(loader)) 121 require.NoError(t, err) 122 require.NotEmpty(t, application) 123 124 // manifest format not matching. 125 manifestWithNoFormat := makeCredentialManifestFromBytes(t, credentialManifestDriversLicenseWithPresentationDefinition) 126 err = cm.ValidateCredentialApplication(application, &manifestWithNoFormat, loader, 127 presexch.WithCredentialOptions(verifiable.WithJSONLDDocumentLoader(loader), 128 verifiable.WithDisabledProofCheck())) 129 require.Contains(t, err.Error(), "invalid format for the given Credential Manifest") 130 131 // manifest ID not matching. 132 manifest.ID = "invalid" 133 err = cm.ValidateCredentialApplication(application, &manifest, loader, 134 presexch.WithCredentialOptions(verifiable.WithJSONLDDocumentLoader(loader), 135 verifiable.WithDisabledProofCheck())) 136 require.Contains(t, err.Error(), "the Manifest ID of the Credential Application "+ 137 "(dcc75a16-19f5-4273-84ce-4da69ee2b7fe) does not match the given Credential Manifest's "+ 138 "ID (invalid)") 139 140 // missing credential application info. 141 delete(application.CustomFields, "credential_application") 142 err = cm.ValidateCredentialApplication(application, &manifest, loader, 143 presexch.WithCredentialOptions(verifiable.WithJSONLDDocumentLoader(loader), 144 verifiable.WithDisabledProofCheck())) 145 require.Contains(t, err.Error(), "invalid credential application, missing 'credential_application'") 146 }) 147 } 148 149 func TestCredentialApplication_Unmarshal(t *testing.T) { 150 t.Run("Success", func(t *testing.T) { 151 makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegree) 152 }) 153 t.Run("Missing ID", func(t *testing.T) { 154 credentialApplicationBytes := makeCredentialApplicationWithMissingID(t) 155 156 var credentialApplication cm.CredentialApplication 157 158 err := json.Unmarshal(credentialApplicationBytes, &credentialApplication) 159 require.EqualError(t, err, "invalid Credential Application: missing ID") 160 }) 161 t.Run("Missing Manifest ID", func(t *testing.T) { 162 credentialApplicationBytes := makeCredentialApplicationWithMissingManifestID(t) 163 164 var credentialApplication cm.CredentialApplication 165 166 err := json.Unmarshal(credentialApplicationBytes, &credentialApplication) 167 require.EqualError(t, err, "invalid Credential Application: missing manifest ID") 168 }) 169 } 170 171 func TestCredentialApplication_ValidateAgainstCredentialManifest(t *testing.T) { 172 t.Run("Credential Manifest has no format and no presentation definition", func(t *testing.T) { 173 t.Run("Credential Application has no format and no presentation definition", func(t *testing.T) { 174 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegree) 175 176 credentialManifest := makeCredentialManifestFromBytes(t, credentialManifestUniversityDegree) 177 178 err := credentialApplication.ValidateAgainstCredentialManifest(&credentialManifest) 179 require.NoError(t, err) 180 }) 181 }) 182 t.Run("Credential Manifest has a format", func(t *testing.T) { 183 t.Run("Credential Application has no format", func(t *testing.T) { 184 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegree) 185 186 credentialManifest := makeCredentialManifestFromBytes(t, credentialManifestUniversityDegreeWithFormat) 187 188 err := credentialApplication.ValidateAgainstCredentialManifest(&credentialManifest) 189 require.EqualError(t, err, "invalid format for the given Credential Manifest: the Credential "+ 190 "Manifest specifies a format but the Credential Application does not") 191 }) 192 t.Run("Credential App requests a JWT format not allowed by the Credential Manifest", func(t *testing.T) { 193 credentialApplication := makeCredentialApplicationWithUnknownJWTAlg(t) 194 195 credentialManifest := makeCredentialManifestFromBytes(t, credentialManifestUniversityDegreeWithFormat) 196 197 err := credentialApplication.ValidateAgainstCredentialManifest(&credentialManifest) 198 require.EqualError(t, err, "invalid format for the given Credential Manifest: invalid format "+ 199 "request: the Credential Application lists the following JWT algorithms: [SomeUnknownFormat ES256K "+ 200 "ES384]. One or more of these are not in the Credential Manifest's supported JWT algorithms: [EdDSA "+ 201 "ES256K ES384]") 202 }) 203 t.Run("Cred App requests a JWT VC format not allowed by the Cred Manifest", func(t *testing.T) { 204 credentialApplication := makeCredentialApplicationWithUnknownJWTVCAlg(t) 205 206 credentialManifest := makeCredentialManifestFromBytes(t, credentialManifestUniversityDegreeWithFormat) 207 208 err := credentialApplication.ValidateAgainstCredentialManifest(&credentialManifest) 209 require.EqualError(t, err, "invalid format for the given Credential Manifest: invalid format "+ 210 "request: the Credential Application lists the following JWT VC algorithms: [SomeUnknownFormat "+ 211 "ES384]. One or more of these are not in the Credential Manifest's supported JWT VC algorithms: "+ 212 "[ES256K ES384]") 213 }) 214 t.Run("Cred App requests a JWT VP format not allowed by the Cred Manifest", func(t *testing.T) { 215 credentialApplication := makeCredentialApplicationWithUnknownJWTVPAlg(t) 216 217 credentialManifest := makeCredentialManifestFromBytes(t, credentialManifestUniversityDegreeWithFormat) 218 219 err := credentialApplication.ValidateAgainstCredentialManifest(&credentialManifest) 220 require.EqualError(t, err, "invalid format for the given Credential Manifest: invalid format "+ 221 "request: the Credential Application lists the following JWT VP algorithms: [SomeUnknownFormat "+ 222 "ES256K]. One or more of these are not in the Credential Manifest's supported JWT VP algorithms: "+ 223 "[EdDSA ES256K]") 224 }) 225 t.Run("Cred App requests an LDP proof type not allowed by the Cred Manifest", func(t *testing.T) { 226 credentialApplication := makeCredentialApplicationWithUnknownLDPProofType(t) 227 228 credentialManifest := makeCredentialManifestFromBytes(t, credentialManifestUniversityDegreeWithFormat) 229 230 err := credentialApplication.ValidateAgainstCredentialManifest(&credentialManifest) 231 require.EqualError(t, err, "invalid format for the given Credential Manifest: invalid format "+ 232 "request: the Credential Application lists the following LDP proof types: [SomeUnknownFormat]. "+ 233 "One or more of these are not in the Credential Manifest's supported LDP proof types: "+ 234 "[RsaSignature2018]") 235 }) 236 t.Run("Cred App requests an LDP VC proof type not allowed by the Cred Manifest", func(t *testing.T) { 237 credentialApplication := makeCredentialApplicationWithUnknownLDPVCProofType(t) 238 239 credentialManifest := makeCredentialManifestFromBytes(t, credentialManifestUniversityDegreeWithFormat) 240 241 err := credentialApplication.ValidateAgainstCredentialManifest(&credentialManifest) 242 require.EqualError(t, err, "invalid format for the given Credential Manifest: invalid format "+ 243 "request: the Credential Application lists the following LDP VC proof types: [SomeUnknownFormat "+ 244 "EcdsaSecp256k1Signature2019 Ed25519Signature2018]. One or more of these are not in the "+ 245 "Credential Manifest's supported LDP VC proof types: [JsonWebSignature2020 Ed25519Signature2018 "+ 246 "EcdsaSecp256k1Signature2019 RsaSignature2018]") 247 }) 248 t.Run("Cred App requests an LDP VC proof type not allowed by the Cred Manifest", func(t *testing.T) { 249 credentialApplication := makeCredentialApplicationWithUnknownLDPVPProofType(t) 250 251 credentialManifest := makeCredentialManifestFromBytes(t, credentialManifestUniversityDegreeWithFormat) 252 253 err := credentialApplication.ValidateAgainstCredentialManifest(&credentialManifest) 254 require.EqualError(t, err, "invalid format for the given Credential Manifest: invalid format "+ 255 "request: the Credential Application lists the following LDP VP proof types: [SomeUnknownFormat]. "+ 256 "One or more of these are not in the Credential Manifest's supported LDP VP proof types: "+ 257 "[Ed25519Signature2018]") 258 }) 259 t.Run("Cred App requests JWT formats but the Cred Manifest's JWT format is nil", func(t *testing.T) { 260 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegreeWithFormat) 261 262 credentialManifest := createCredentialManifestWithNilJWTFormat(t) 263 264 err := credentialApplication.ValidateAgainstCredentialManifest(&credentialManifest) 265 require.EqualError(t, err, "invalid format for the given Credential Manifest: invalid format "+ 266 "request: the Credential Application lists the following JWT algorithms: [EdDSA ES256K ES384]. "+ 267 "One or more of these are not in the Credential Manifest's supported JWT algorithms: []") 268 }) 269 t.Run("Cred App requests JWT formats but the Cred Manifest's LDP format is nil", func(t *testing.T) { 270 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegreeWithFormat) 271 272 credentialManifest := createCredentialManifestWithNilLDPFormat(t) 273 274 err := credentialApplication.ValidateAgainstCredentialManifest(&credentialManifest) 275 require.EqualError(t, err, "invalid format for the given Credential Manifest: invalid format "+ 276 "request: the Credential Application lists the following LDP proof types: [RsaSignature2018]. One "+ 277 "or more of these are not in the Credential Manifest's supported LDP proof types: []") 278 }) 279 t.Run("Credential Application has a valid format", func(t *testing.T) { 280 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegreeWithFormat) 281 282 credentialManifest := makeCredentialManifestFromBytes(t, credentialManifestUniversityDegreeWithFormat) 283 284 err := credentialApplication.ValidateAgainstCredentialManifest(&credentialManifest) 285 require.NoError(t, err) 286 }) 287 }) 288 t.Run("Credential Manifest has no format", func(t *testing.T) { 289 t.Run("Credential Application has a format", func(t *testing.T) { 290 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegreeWithFormat) 291 292 credentialManifest := makeCredentialManifestFromBytes(t, credentialManifestUniversityDegree) 293 require.Empty(t, credentialManifest.Format) 294 err := credentialApplication.ValidateAgainstCredentialManifest(&credentialManifest) 295 require.EqualError(t, err, "invalid format for the given Credential Manifest: the Credential Application "+ 296 "specifies a format but the Credential Manifest does not") 297 }) 298 }) 299 t.Run("Credential App's manifest ID does not match the given Credential Manifest", func(t *testing.T) { 300 credentialApplication := makeCredentialApplicationWithUnknownManifestID(t) 301 302 credentialManifest := makeCredentialManifestFromBytes(t, credentialManifestUniversityDegree) 303 304 err := credentialApplication.ValidateAgainstCredentialManifest(&credentialManifest) 305 require.EqualError(t, err, "the Manifest ID of the Credential Application (SomeUnknownManifestID) "+ 306 "does not match the given Credential Manifest's ID (university_degree)") 307 }) 308 } 309 310 func TestPresentCredentialApplication(t *testing.T) { 311 t.Run("Successes", func(t *testing.T) { 312 testTable := map[string]struct { 313 existingPresentation []byte 314 credentialManifest []byte 315 expectedPresentation []byte 316 }{ 317 "Without existing presentation, Credential Manifest has no Presentation Definition and no format": { 318 existingPresentation: nil, 319 credentialManifest: credentialManifestDriversLicense, 320 expectedPresentation: vpMinimalWithCredentialApplication, 321 }, 322 "With existing presentation, Credential Manifest has no Presentation Definition and no format": { 323 existingPresentation: vpWithPRCardVC, 324 credentialManifest: credentialManifestDriversLicense, 325 expectedPresentation: vpWithPRCardVCAndCredentialApplication, 326 }, 327 "Without existing presentation, Credential Manifest has a Presentation Definition but no format": { 328 existingPresentation: nil, 329 credentialManifest: credentialManifestDriversLicenseWithPresentationDefinition, 330 expectedPresentation: vpMinimalWithCredentialApplicationAndPresentationSubmission, 331 }, 332 "With existing presentation, Credential Manifest has a Presentation Definition but no format": { 333 existingPresentation: vpWithPRCardVC, 334 credentialManifest: credentialManifestDriversLicenseWithPresentationDefinition, 335 expectedPresentation: vpWithPRCardVCAndCredentialApplicationAndPresentationSubmission, 336 }, 337 "Without existing presentation, Credential Manifest has a Presentation Definition and format": { 338 existingPresentation: nil, 339 credentialManifest: credentialManifestDriversLicenseWithPresentationDefinitionAndFormat, 340 expectedPresentation: vpMinimalWithCredentialApplicationAndPresentationSubmissionAndFormat, 341 }, 342 "With existing presentation, Credential Manifest has a Presentation Definition and format": { 343 existingPresentation: vpWithPRCardVC, 344 credentialManifest: credentialManifestDriversLicenseWithPresentationDefinitionAndFormat, 345 expectedPresentation: vpWithPRCardVCAndCredentialApplicationAndPresentationSubmissionAndFormat, 346 }, 347 "With existing presentation that uses Presentation Exchange context, " + 348 "Credential Manifest has no Presentation Definition and no format": { 349 existingPresentation: vpWithPRCardVCUsingPresentationExchangeContext, 350 credentialManifest: credentialManifestDriversLicense, 351 expectedPresentation: vpWithPRCardVCAndCredentialApplication, 352 }, 353 } 354 355 for testName, testData := range testTable { 356 credentialManifest := makeCredentialManifestFromBytes(t, testData.credentialManifest) 357 358 var option cm.PresentCredentialApplicationOpt 359 360 if testData.existingPresentation != nil { 361 existingPresentation := makePresentationFromBytes(t, testData.existingPresentation, testName) 362 363 option = cm.WithExistingPresentationForPresentCredentialApplication(existingPresentation) 364 } 365 366 presentation, err := cm.PresentCredentialApplication(&credentialManifest, option) 367 require.NoError(t, err, errorMessageTestNameFormat, testName) 368 require.NotNil(t, presentation, errorMessageTestNameFormat, testName) 369 370 reunmarshalledPresentation := marshalThenUnmarshalAgain(t, presentation, testName) 371 372 expectedPresentation := makePresentationFromBytes(t, testData.expectedPresentation, testName) 373 374 makeCredentialApplicationIDsTheSame(t, reunmarshalledPresentation, expectedPresentation, testName) 375 makePresentationSubmissionIDsTheSame(reunmarshalledPresentation, expectedPresentation) 376 377 require.True(t, reflect.DeepEqual(reunmarshalledPresentation, expectedPresentation), errorMessageTestNameFormat+ 378 " the presentation with a Credential Response added to it differs from what was expected", testName) 379 } 380 }) 381 t.Run("Nil Credential Manifest argument", func(t *testing.T) { 382 presentation, err := cm.PresentCredentialApplication(nil) 383 require.EqualError(t, err, "credential manifest argument cannot be nil") 384 require.Nil(t, presentation) 385 }) 386 } 387 388 func makeCredentialApplicationIDsTheSame(t *testing.T, presentation1, 389 presentation2 *verifiable.Presentation, testName string) { 390 credentialApplicationFromPresentation1, ok := 391 presentation1.CustomFields["credential_application"].(map[string]interface{}) 392 require.True(t, ok, errorMessageTestNameFormat, testName) 393 394 credentialApplicationFromPresentation2, ok := 395 presentation2.CustomFields["credential_application"].(map[string]interface{}) 396 require.True(t, ok, errorMessageTestNameFormat, testName) 397 398 credentialApplicationFromPresentation2["id"] = credentialApplicationFromPresentation1["id"] 399 } 400 401 // If either presentation is missing a presentation_submission field, then this function returns without 402 // changing anything. 403 func makePresentationSubmissionIDsTheSame(presentation1, presentation2 *verifiable.Presentation) { 404 credentialSubmissionFromPresentation1, ok := 405 presentation1.CustomFields["presentation_submission"].(map[string]interface{}) 406 if !ok { 407 return 408 } 409 410 credentialSubmissionFromPresentation2, ok := 411 presentation2.CustomFields["presentation_submission"].(map[string]interface{}) 412 if !ok { 413 return 414 } 415 416 credentialSubmissionFromPresentation2["id"] = credentialSubmissionFromPresentation1["id"] 417 } 418 419 func makeCredentialApplicationFromBytes(t *testing.T, 420 credentialApplicationBytes []byte) cm.CredentialApplication { 421 var credentialApplication cm.CredentialApplication 422 423 err := json.Unmarshal(credentialApplicationBytes, &credentialApplication) 424 require.NoError(t, err) 425 426 return credentialApplication 427 } 428 429 func makeCredentialApplicationWithMissingID(t *testing.T) []byte { 430 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegree) 431 432 credentialApplication.ID = "" 433 434 credentialApplicationBytes, err := json.Marshal(credentialApplication) 435 require.NoError(t, err) 436 437 return credentialApplicationBytes 438 } 439 440 func makeCredentialApplicationWithMissingManifestID(t *testing.T) []byte { 441 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegree) 442 443 credentialApplication.ManifestID = "" 444 445 credentialApplicationBytes, err := json.Marshal(credentialApplication) 446 require.NoError(t, err) 447 448 return credentialApplicationBytes 449 } 450 451 func makeCredentialApplicationWithUnknownJWTAlg(t *testing.T) cm.CredentialApplication { 452 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegreeWithFormat) 453 454 credentialApplication.Format.Jwt.Alg[0] = unknownFormatName 455 456 return credentialApplication 457 } 458 459 func makeCredentialApplicationWithUnknownJWTVCAlg(t *testing.T) cm.CredentialApplication { 460 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegreeWithFormat) 461 462 credentialApplication.Format.JwtVC.Alg[0] = unknownFormatName 463 464 return credentialApplication 465 } 466 467 func makeCredentialApplicationWithUnknownJWTVPAlg(t *testing.T) cm.CredentialApplication { 468 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegreeWithFormat) 469 470 credentialApplication.Format.JwtVP.Alg[0] = unknownFormatName 471 472 return credentialApplication 473 } 474 475 func makeCredentialApplicationWithUnknownLDPProofType(t *testing.T) cm.CredentialApplication { 476 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegreeWithFormat) 477 478 credentialApplication.Format.Ldp.ProofType[0] = unknownFormatName 479 480 return credentialApplication 481 } 482 483 func makeCredentialApplicationWithUnknownLDPVCProofType(t *testing.T) cm.CredentialApplication { 484 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegreeWithFormat) 485 486 credentialApplication.Format.LdpVC.ProofType[0] = unknownFormatName 487 488 return credentialApplication 489 } 490 491 func makeCredentialApplicationWithUnknownLDPVPProofType(t *testing.T) cm.CredentialApplication { 492 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegreeWithFormat) 493 494 credentialApplication.Format.LdpVP.ProofType[0] = unknownFormatName 495 496 return credentialApplication 497 } 498 499 func makeCredentialApplicationWithUnknownManifestID(t *testing.T) cm.CredentialApplication { 500 credentialApplication := makeCredentialApplicationFromBytes(t, credentialApplicationUniversityDegreeWithFormat) 501 502 credentialApplication.ManifestID = "SomeUnknownManifestID" 503 504 return credentialApplication 505 }