@@ -545,239 +545,17 @@ async fn test_revoke_client_tokens() {
545545}
546546
547547// =============================================================================
548- // Client Grants Tests (Feature Set Permissions)
548+ // Client Grants Tests — REMOVED in migration 003.
549+ //
550+ // The `client_grants` table and the repository methods that backed it were
551+ // dropped once the FeatureSetResolver (pin > workspace binding > space-active)
552+ // became authoritative. The trait methods remain as no-op shims for API
553+ // compatibility with Tauri commands, but they no longer persist anything.
554+ //
555+ // For resolver decision-table tests see
556+ // `tests/integration/feature_set_resolver.rs`.
549557// =============================================================================
550558
551- #[ tokio:: test]
552- async fn test_grant_feature_set ( ) {
553- let test_db = TestDatabase :: new ( ) ;
554- let db = Arc :: new ( Mutex :: new ( test_db. db ) ) ;
555- let repo = InboundClientRepository :: new ( Arc :: clone ( & db) ) ;
556- let space_repo = SqliteSpaceRepository :: new ( db) ;
557-
558- // Create a space (auto-creates All and Default feature sets)
559- let space = fixtures:: test_space ( "Test Space" ) ;
560- SpaceRepository :: create ( & space_repo, & space) . await . unwrap ( ) ;
561-
562- let client = create_test_client ( "Grant Client" ) ;
563- repo. save_client ( & client) . await . unwrap ( ) ;
564-
565- // Grant the auto-created "All" feature set
566- let all_fs_id = format ! ( "fs_all_{}" , space. id) ;
567- repo. grant_feature_set ( & client. client_id , & space. id . to_string ( ) , & all_fs_id)
568- . await
569- . expect ( "Failed to grant" ) ;
570-
571- // Check grants
572- let grants = repo
573- . get_grants_for_space ( & client. client_id , & space. id . to_string ( ) )
574- . await
575- . unwrap ( ) ;
576- assert_eq ! ( grants. len( ) , 1 ) ;
577- assert ! ( grants. contains( & all_fs_id) ) ;
578- }
579-
580- #[ tokio:: test]
581- async fn test_grant_multiple_feature_sets ( ) {
582- let test_db = TestDatabase :: new ( ) ;
583- let db = Arc :: new ( Mutex :: new ( test_db. db ) ) ;
584- let repo = InboundClientRepository :: new ( Arc :: clone ( & db) ) ;
585- let space_repo = SqliteSpaceRepository :: new ( db) ;
586-
587- // Create two spaces
588- let space1 = fixtures:: test_space ( "Space 1" ) ;
589- let space2 = fixtures:: test_space ( "Space 2" ) ;
590- SpaceRepository :: create ( & space_repo, & space1) . await . unwrap ( ) ;
591- SpaceRepository :: create ( & space_repo, & space2) . await . unwrap ( ) ;
592-
593- let client = create_test_client ( "Multi Grant" ) ;
594- repo. save_client ( & client) . await . unwrap ( ) ;
595-
596- // Use auto-created feature set IDs
597- let space1_all = format ! ( "fs_all_{}" , space1. id) ;
598- let space1_default = format ! ( "fs_default_{}" , space1. id) ;
599- let space2_all = format ! ( "fs_all_{}" , space2. id) ;
600-
601- repo. grant_feature_set ( & client. client_id , & space1. id . to_string ( ) , & space1_all)
602- . await
603- . unwrap ( ) ;
604- repo. grant_feature_set ( & client. client_id , & space1. id . to_string ( ) , & space1_default)
605- . await
606- . unwrap ( ) ;
607- repo. grant_feature_set ( & client. client_id , & space2. id . to_string ( ) , & space2_all)
608- . await
609- . unwrap ( ) ;
610-
611- // Space 1 should have 2
612- let grants1 = repo
613- . get_grants_for_space ( & client. client_id , & space1. id . to_string ( ) )
614- . await
615- . unwrap ( ) ;
616- assert_eq ! ( grants1. len( ) , 2 ) ;
617-
618- // Space 2 should have 1
619- let grants2 = repo
620- . get_grants_for_space ( & client. client_id , & space2. id . to_string ( ) )
621- . await
622- . unwrap ( ) ;
623- assert_eq ! ( grants2. len( ) , 1 ) ;
624- }
625-
626- #[ tokio:: test]
627- async fn test_grant_idempotent ( ) {
628- let test_db = TestDatabase :: new ( ) ;
629- let db = Arc :: new ( Mutex :: new ( test_db. db ) ) ;
630- let repo = InboundClientRepository :: new ( Arc :: clone ( & db) ) ;
631- let space_repo = SqliteSpaceRepository :: new ( db) ;
632-
633- let space = fixtures:: test_space ( "Test Space" ) ;
634- SpaceRepository :: create ( & space_repo, & space) . await . unwrap ( ) ;
635-
636- let client = create_test_client ( "Idempotent" ) ;
637- repo. save_client ( & client) . await . unwrap ( ) ;
638-
639- let all_fs_id = format ! ( "fs_all_{}" , space. id) ;
640-
641- // Grant same thing twice
642- repo. grant_feature_set ( & client. client_id , & space. id . to_string ( ) , & all_fs_id)
643- . await
644- . unwrap ( ) ;
645- repo. grant_feature_set ( & client. client_id , & space. id . to_string ( ) , & all_fs_id)
646- . await
647- . unwrap ( ) ;
648-
649- // Should still be 1
650- let grants = repo
651- . get_grants_for_space ( & client. client_id , & space. id . to_string ( ) )
652- . await
653- . unwrap ( ) ;
654- assert_eq ! ( grants. len( ) , 1 ) ;
655- }
656-
657- #[ tokio:: test]
658- async fn test_revoke_feature_set ( ) {
659- let test_db = TestDatabase :: new ( ) ;
660- let db = Arc :: new ( Mutex :: new ( test_db. db ) ) ;
661- let repo = InboundClientRepository :: new ( Arc :: clone ( & db) ) ;
662- let space_repo = SqliteSpaceRepository :: new ( db) ;
663-
664- let space = fixtures:: test_space ( "Test Space" ) ;
665- SpaceRepository :: create ( & space_repo, & space) . await . unwrap ( ) ;
666-
667- let client = create_test_client ( "Revoke Grant" ) ;
668- repo. save_client ( & client) . await . unwrap ( ) ;
669-
670- let all_fs_id = format ! ( "fs_all_{}" , space. id) ;
671- let default_fs_id = format ! ( "fs_default_{}" , space. id) ;
672-
673- repo. grant_feature_set ( & client. client_id , & space. id . to_string ( ) , & all_fs_id)
674- . await
675- . unwrap ( ) ;
676- repo. grant_feature_set ( & client. client_id , & space. id . to_string ( ) , & default_fs_id)
677- . await
678- . unwrap ( ) ;
679-
680- // Revoke one
681- repo. revoke_feature_set ( & client. client_id , & space. id . to_string ( ) , & all_fs_id)
682- . await
683- . expect ( "Failed to revoke" ) ;
684-
685- // Only default remains
686- let grants = repo
687- . get_grants_for_space ( & client. client_id , & space. id . to_string ( ) )
688- . await
689- . unwrap ( ) ;
690- assert_eq ! ( grants. len( ) , 1 ) ;
691- assert ! ( grants. contains( & default_fs_id) ) ;
692- }
693-
694- #[ tokio:: test]
695- async fn test_get_all_grants ( ) {
696- let test_db = TestDatabase :: new ( ) ;
697- let db = Arc :: new ( Mutex :: new ( test_db. db ) ) ;
698- let repo = InboundClientRepository :: new ( Arc :: clone ( & db) ) ;
699- let space_repo = SqliteSpaceRepository :: new ( db) ;
700-
701- let space1 = fixtures:: test_space ( "Space 1" ) ;
702- let space2 = fixtures:: test_space ( "Space 2" ) ;
703- SpaceRepository :: create ( & space_repo, & space1) . await . unwrap ( ) ;
704- SpaceRepository :: create ( & space_repo, & space2) . await . unwrap ( ) ;
705-
706- let client = create_test_client ( "All Grants" ) ;
707- repo. save_client ( & client) . await . unwrap ( ) ;
708-
709- let space1_all = format ! ( "fs_all_{}" , space1. id) ;
710- let space1_default = format ! ( "fs_default_{}" , space1. id) ;
711- let space2_all = format ! ( "fs_all_{}" , space2. id) ;
712-
713- repo. grant_feature_set ( & client. client_id , & space1. id . to_string ( ) , & space1_all)
714- . await
715- . unwrap ( ) ;
716- repo. grant_feature_set ( & client. client_id , & space1. id . to_string ( ) , & space1_default)
717- . await
718- . unwrap ( ) ;
719- repo. grant_feature_set ( & client. client_id , & space2. id . to_string ( ) , & space2_all)
720- . await
721- . unwrap ( ) ;
722-
723- let all_grants = repo
724- . get_all_grants ( & client. client_id )
725- . await
726- . expect ( "Failed to get all" ) ;
727- assert_eq ! ( all_grants. len( ) , 2 ) ; // 2 spaces
728-
729- assert_eq ! ( all_grants. get( & space1. id. to_string( ) ) . unwrap( ) . len( ) , 2 ) ;
730- assert_eq ! ( all_grants. get( & space2. id. to_string( ) ) . unwrap( ) . len( ) , 1 ) ;
731- }
732-
733- #[ tokio:: test]
734- async fn test_grants_per_space_isolation ( ) {
735- let test_db = TestDatabase :: new ( ) ;
736- let db = Arc :: new ( Mutex :: new ( test_db. db ) ) ;
737- let repo = InboundClientRepository :: new ( Arc :: clone ( & db) ) ;
738- let space_repo = SqliteSpaceRepository :: new ( db) ;
739-
740- let work = fixtures:: test_space ( "Work" ) ;
741- let personal = fixtures:: test_space ( "Personal" ) ;
742- SpaceRepository :: create ( & space_repo, & work) . await . unwrap ( ) ;
743- SpaceRepository :: create ( & space_repo, & personal)
744- . await
745- . unwrap ( ) ;
746-
747- let client = create_test_client ( "Space Isolation" ) ;
748- repo. save_client ( & client) . await . unwrap ( ) ;
749-
750- let work_all = format ! ( "fs_all_{}" , work. id) ;
751- let personal_all = format ! ( "fs_all_{}" , personal. id) ;
752-
753- // Grant "All" in different spaces
754- repo. grant_feature_set ( & client. client_id , & work. id . to_string ( ) , & work_all)
755- . await
756- . unwrap ( ) ;
757- repo. grant_feature_set ( & client. client_id , & personal. id . to_string ( ) , & personal_all)
758- . await
759- . unwrap ( ) ;
760-
761- // Revoke from work only
762- repo. revoke_feature_set ( & client. client_id , & work. id . to_string ( ) , & work_all)
763- . await
764- . unwrap ( ) ;
765-
766- // Work should be empty
767- let work_grants = repo
768- . get_grants_for_space ( & client. client_id , & work. id . to_string ( ) )
769- . await
770- . unwrap ( ) ;
771- assert ! ( work_grants. is_empty( ) ) ;
772-
773- // Personal still has grant
774- let personal_grants = repo
775- . get_grants_for_space ( & client. client_id , & personal. id . to_string ( ) )
776- . await
777- . unwrap ( ) ;
778- assert_eq ! ( personal_grants. len( ) , 1 ) ;
779- }
780-
781559// =============================================================================
782560// Client Settings Update Tests
783561// =============================================================================
0 commit comments