@@ -556,3 +556,67 @@ def premium_system_authenticated_access(
556556 if extra_auth_policy .exists :
557557 LOGGER .info (f"Fixture teardown: ensuring AuthPolicy { extra_auth_policy .name } is removed" )
558558 extra_auth_policy .clean_up (wait = True )
559+
560+
561+ @pytest .fixture (scope = "function" )
562+ def second_free_subscription (
563+ admin_client : DynamicClient ,
564+ maas_free_group : str ,
565+ maas_model_tinyllama_free : MaaSModelRef ,
566+ maas_subscription_tinyllama_free : MaaSSubscription ,
567+ ) -> Generator [MaaSSubscription , Any , Any ]:
568+ """
569+ Creates a second subscription for maas_free_group on the free model.
570+ Used to simulate an ambiguous subscription selection (two qualifying subscriptions,
571+ no x-maas-subscription header).
572+ """
573+ with create_maas_subscription (
574+ admin_client = admin_client ,
575+ subscription_namespace = maas_subscription_tinyllama_free .namespace ,
576+ subscription_name = "e2e-second-free-subscription" ,
577+ owner_group_name = maas_free_group ,
578+ model_name = maas_model_tinyllama_free .name ,
579+ model_namespace = maas_model_tinyllama_free .namespace ,
580+ tokens_per_minute = 500 ,
581+ window = "1m" ,
582+ priority = 5 ,
583+ teardown = True ,
584+ wait_for_resource = True ,
585+ ) as second_subscription :
586+ second_subscription .wait_for_condition (condition = "Ready" , status = "True" , timeout = 300 )
587+ LOGGER .info (
588+ f"Created second free subscription { second_subscription .name } for model { maas_model_tinyllama_free .name } "
589+ )
590+ yield second_subscription
591+
592+
593+ @pytest .fixture (scope = "function" )
594+ def free_actor_premium_subscription (
595+ admin_client : DynamicClient ,
596+ maas_model_tinyllama_premium : MaaSModelRef ,
597+ maas_subscription_tinyllama_premium : MaaSSubscription ,
598+ ) -> Generator [MaaSSubscription , Any , Any ]:
599+ """
600+ Creates a subscription for system:authenticated on the premium model.
601+ Used to verify that having a subscription alone is not sufficient —
602+ the actor must also be listed in the model's MaaSAuthPolicy.
603+ """
604+ with create_maas_subscription (
605+ admin_client = admin_client ,
606+ subscription_namespace = maas_subscription_tinyllama_premium .namespace ,
607+ subscription_name = "e2e-free-actor-premium-sub" ,
608+ owner_group_name = "system:authenticated" ,
609+ model_name = maas_model_tinyllama_premium .name ,
610+ model_namespace = maas_model_tinyllama_premium .namespace ,
611+ tokens_per_minute = 100 ,
612+ window = "1m" ,
613+ priority = 0 ,
614+ teardown = True ,
615+ wait_for_resource = True ,
616+ ) as sub_for_free_actor :
617+ sub_for_free_actor .wait_for_condition (condition = "Ready" , status = "True" , timeout = 300 )
618+ LOGGER .info (
619+ f"Created subscription { sub_for_free_actor .name } for system:authenticated "
620+ f"on premium model { maas_model_tinyllama_premium .name } "
621+ )
622+ yield sub_for_free_actor
0 commit comments