An easy-to-host PDS on the ATProtocol, iPhone and MacOS. Maintain control of your keys and data, always.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: apply cargo fmt to resolve formatting violations in create_did.rs test module

- Fixed alignment of trailing comments in function call arguments
- Normalized spacing after commas (removed excessive space for alignment)
- Reformatted multi-line assert! macro calls for consistency
- Improved line wrapping for method chains and struct literals

All formatting violations (approx. 18) in the test module have been resolved.

authored by

Malpercio and committed by
Tangled
6f6eacef c246a14b

+105 -30
+105 -30
crates/relay/src/routes/create_did.rs
··· 372 372 let kp = generate_p256_keypair().expect("keypair"); 373 373 let private_bytes = *kp.private_key_bytes; 374 374 let genesis_op = build_did_plc_genesis_op( 375 - &kp.key_id, // rotation key — placed at rotationKeys[0] 376 - &kp.key_id, // signing key (same) — kp's private key performs the signing 375 + &kp.key_id, // rotation key — placed at rotationKeys[0] 376 + &kp.key_id, // signing key (same) — kp's private key performs the signing 377 377 &private_bytes, 378 378 handle, 379 379 public_url, ··· 446 446 .await 447 447 .expect("insert pending_session"); 448 448 449 - TestSetup { session_token, account_id, handle } 449 + TestSetup { 450 + session_token, 451 + account_id, 452 + handle, 453 + } 450 454 } 451 455 452 456 /// Create an AppState with plc_directory_url pointing to the mock server. ··· 497 501 498 502 let app = crate::app::app(state.clone()); 499 503 let response = app 500 - .oneshot(create_did_request(&setup.session_token, &rotation_key_public, &signed_op)) 504 + .oneshot(create_did_request( 505 + &setup.session_token, 506 + &rotation_key_public, 507 + &signed_op, 508 + )) 501 509 .await 502 510 .unwrap(); 503 511 504 512 // AC2.1: 200 OK with { did, did_document, status: "active" } 505 513 assert_eq!(response.status(), StatusCode::OK, "expected 200 OK"); 506 - let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX).await.unwrap(); 514 + let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX) 515 + .await 516 + .unwrap(); 507 517 let body: serde_json::Value = serde_json::from_slice(&body_bytes).unwrap(); 508 518 assert!( 509 - body["did"].as_str().map(|d| d.starts_with("did:plc:")).unwrap_or(false), 519 + body["did"] 520 + .as_str() 521 + .map(|d| d.starts_with("did:plc:")) 522 + .unwrap_or(false), 510 523 "did should start with did:plc:" 511 524 ); 512 525 assert_eq!(body["status"], "active", "status should be active"); 513 - assert!(body["did_document"].is_object(), "did_document should be a JSON object"); 526 + assert!( 527 + body["did_document"].is_object(), 528 + "did_document should be a JSON object" 529 + ); 514 530 515 531 let did = body["did"].as_str().unwrap(); 516 532 let doc = &body["did_document"]; ··· 518 534 // AC4.2: alsoKnownAs contains at://{handle} 519 535 let also_known_as = doc["alsoKnownAs"].as_array().expect("alsoKnownAs is array"); 520 536 assert!( 521 - also_known_as.iter().any(|e| e.as_str() == Some(&format!("at://{}", setup.handle))), 522 - "alsoKnownAs should contain at://{}", setup.handle 537 + also_known_as 538 + .iter() 539 + .any(|e| e.as_str() == Some(&format!("at://{}", setup.handle))), 540 + "alsoKnownAs should contain at://{}", 541 + setup.handle 523 542 ); 524 543 525 544 // AC4.1: verificationMethod has publicKeyMultibase starting with "z" 526 545 let vm = &doc["verificationMethod"][0]; 527 - let pkm = vm["publicKeyMultibase"].as_str().expect("publicKeyMultibase is string"); 528 - assert!(pkm.starts_with('z'), "publicKeyMultibase should start with 'z'"); 546 + let pkm = vm["publicKeyMultibase"] 547 + .as_str() 548 + .expect("publicKeyMultibase is string"); 549 + assert!( 550 + pkm.starts_with('z'), 551 + "publicKeyMultibase should start with 'z'" 552 + ); 529 553 530 554 // AC4.3: service entry has serviceEndpoint matching public_url 531 555 let service = &doc["service"][0]; ··· 544 568 .unwrap(); 545 569 let (email, password_hash) = row.expect("accounts row should exist"); 546 570 assert!(email.contains("alice"), "email should match test account"); 547 - assert!(password_hash.is_none(), "password_hash should be NULL for device-provisioned account"); 571 + assert!( 572 + password_hash.is_none(), 573 + "password_hash should be NULL for device-provisioned account" 574 + ); 548 575 549 576 // AC2.3: did_documents row exists with non-empty document 550 577 let doc_row: Option<(String,)> = ··· 622 649 623 650 let app = crate::app::app(state); 624 651 let response = app 625 - .oneshot(create_did_request(&setup.session_token, &rotation_key_public, &signed_op)) 652 + .oneshot(create_did_request( 653 + &setup.session_token, 654 + &rotation_key_public, 655 + &signed_op, 656 + )) 626 657 .await 627 658 .unwrap(); 628 659 629 660 assert_eq!(response.status(), StatusCode::OK, "retry should return 200"); 630 - let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX).await.unwrap(); 661 + let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX) 662 + .await 663 + .unwrap(); 631 664 let body: serde_json::Value = serde_json::from_slice(&body_bytes).unwrap(); 632 - assert_eq!(body["did"].as_str(), Some(verified.did.as_str()), "did should match pre-computed DID"); 665 + assert_eq!( 666 + body["did"].as_str(), 667 + Some(verified.did.as_str()), 668 + "did should match pre-computed DID" 669 + ); 633 670 // wiremock verifies expect(0) on mock_server drop 634 671 } 635 672 ··· 652 689 653 690 let app = crate::app::app(state); 654 691 let response = app 655 - .oneshot(create_did_request(&setup.session_token, &rotation_key_public, &signed_op)) 692 + .oneshot(create_did_request( 693 + &setup.session_token, 694 + &rotation_key_public, 695 + &signed_op, 696 + )) 656 697 .await 657 698 .unwrap(); 658 699 659 700 assert_eq!(response.status(), StatusCode::BAD_REQUEST, "expected 400"); 660 - let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX).await.unwrap(); 701 + let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX) 702 + .await 703 + .unwrap(); 661 704 let body: serde_json::Value = serde_json::from_slice(&body_bytes).unwrap(); 662 705 assert_eq!(body["error"]["code"], "INVALID_CLAIM"); 663 706 } ··· 676 719 677 720 let app = crate::app::app(state); 678 721 let response = app 679 - .oneshot(create_did_request(&setup.session_token, &rotation_key_public, &signed_op)) 722 + .oneshot(create_did_request( 723 + &setup.session_token, 724 + &rotation_key_public, 725 + &signed_op, 726 + )) 680 727 .await 681 728 .unwrap(); 682 729 683 730 assert_eq!(response.status(), StatusCode::BAD_REQUEST, "expected 400"); 684 - let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX).await.unwrap(); 731 + let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX) 732 + .await 733 + .unwrap(); 685 734 let body: serde_json::Value = serde_json::from_slice(&body_bytes).unwrap(); 686 735 assert_eq!(body["error"]["code"], "INVALID_CLAIM"); 687 736 } ··· 700 749 701 750 let app = crate::app::app(state); 702 751 let response = app 703 - .oneshot(create_did_request(&setup.session_token, &rotation_key_public, &signed_op)) 752 + .oneshot(create_did_request( 753 + &setup.session_token, 754 + &rotation_key_public, 755 + &signed_op, 756 + )) 704 757 .await 705 758 .unwrap(); 706 759 707 760 assert_eq!(response.status(), StatusCode::BAD_REQUEST, "expected 400"); 708 - let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX).await.unwrap(); 761 + let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX) 762 + .await 763 + .unwrap(); 709 764 let body: serde_json::Value = serde_json::from_slice(&body_bytes).unwrap(); 710 765 assert_eq!(body["error"]["code"], "INVALID_CLAIM"); 711 766 } ··· 731 786 732 787 // Build op: rotationKeys[0] = kp_y, signing key = kp_x (signs with kp_x). 733 788 let genesis_op = build_did_plc_genesis_op( 734 - &kp_y.key_id, // rotationKeys[0] = kp_y 735 - &kp_x.key_id, // signing key = kp_x, signs with kp_x's private key 789 + &kp_y.key_id, // rotationKeys[0] = kp_y 790 + &kp_x.key_id, // signing key = kp_x, signs with kp_x's private key 736 791 &x_private, 737 792 &setup.handle, 738 793 &state.config.public_url, ··· 746 801 // but rotation_keys[0] == kp_y ≠ kp_x → semantic validation fails. 747 802 let app = crate::app::app(state); 748 803 let response = app 749 - .oneshot(create_did_request(&setup.session_token, &kp_x.key_id.0, &signed_op)) 804 + .oneshot(create_did_request( 805 + &setup.session_token, 806 + &kp_x.key_id.0, 807 + &signed_op, 808 + )) 750 809 .await 751 810 .unwrap(); 752 811 753 812 assert_eq!(response.status(), StatusCode::BAD_REQUEST, "expected 400"); 754 - let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX).await.unwrap(); 813 + let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX) 814 + .await 815 + .unwrap(); 755 816 let body: serde_json::Value = serde_json::from_slice(&body_bytes).unwrap(); 756 817 assert_eq!(body["error"]["code"], "INVALID_CLAIM"); 757 818 } ··· 785 846 786 847 let app = crate::app::app(state); 787 848 let response = app 788 - .oneshot(create_did_request(&setup.session_token, &rotation_key_public, &signed_op)) 849 + .oneshot(create_did_request( 850 + &setup.session_token, 851 + &rotation_key_public, 852 + &signed_op, 853 + )) 789 854 .await 790 855 .unwrap(); 791 856 792 857 assert_eq!(response.status(), StatusCode::CONFLICT, "expected 409"); 793 - let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX).await.unwrap(); 858 + let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX) 859 + .await 860 + .unwrap(); 794 861 let body: serde_json::Value = serde_json::from_slice(&body_bytes).unwrap(); 795 862 assert_eq!(body["error"]["code"], "DID_ALREADY_EXISTS"); 796 863 } ··· 819 886 let response = app.oneshot(request).await.unwrap(); 820 887 821 888 assert_eq!(response.status(), StatusCode::UNAUTHORIZED, "expected 401"); 822 - let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX).await.unwrap(); 889 + let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX) 890 + .await 891 + .unwrap(); 823 892 let body: serde_json::Value = serde_json::from_slice(&body_bytes).unwrap(); 824 893 assert_eq!(body["error"]["code"], "UNAUTHORIZED"); 825 894 } ··· 846 915 847 916 let app = crate::app::app(state); 848 917 let response = app 849 - .oneshot(create_did_request(&setup.session_token, &rotation_key_public, &signed_op)) 918 + .oneshot(create_did_request( 919 + &setup.session_token, 920 + &rotation_key_public, 921 + &signed_op, 922 + )) 850 923 .await 851 924 .unwrap(); 852 925 853 926 assert_eq!(response.status(), StatusCode::BAD_GATEWAY, "expected 502"); 854 - let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX).await.unwrap(); 927 + let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX) 928 + .await 929 + .unwrap(); 855 930 let body: serde_json::Value = serde_json::from_slice(&body_bytes).unwrap(); 856 931 assert_eq!(body["error"]["code"], "PLC_DIRECTORY_ERROR"); 857 932 }