44from notifications_python_client .authentication import create_jwt_token
55
66from app .models import EMAIL_TYPE , SMS_TYPE
7- from tests .app .db import create_template
7+ from tests .app .db import create_service , create_template
88
99
1010def _auth_header (api_key ):
@@ -48,7 +48,9 @@ def test_get_template_returns_richer_fields_than_v2(self, client, sample_service
4848 assert "archived" in data
4949 assert "template_category_id" in data
5050 assert "folder_id" in data
51- assert "process_type" in data
51+
52+ # process_type is intentionally NOT exposed in v3
53+ assert "process_type" not in data
5254
5355 # Core fields still present
5456 assert "id" in data
@@ -73,7 +75,8 @@ def test_get_template_returns_403_without_manage_templates_permission(self, clie
7375
7476 assert response .status_code == 403
7577 data = json .loads (response .get_data (as_text = True ))
76- assert "manage templates" in data ["message" ].lower () or "manage_templates" in data ["message" ].lower ()
78+ message = data ["errors" ][0 ]["message" ].lower ()
79+ assert "manage templates" in message or "manage_templates" in message
7780
7881 def test_get_template_returns_404_for_nonexistent_template (self , client , sample_service , create_api_key_with_manage_api_perm ):
7982 nonexistent_id = uuid .uuid4 ()
@@ -87,20 +90,19 @@ def test_get_template_returns_404_for_nonexistent_template(self, client, sample_
8790 assert response .status_code == 404
8891
8992 def test_get_template_returns_404_for_template_belonging_to_other_service (
90- self , client , sample_service , sample_template , create_api_key_with_manage_api_perm
93+ self , client , sample_service , create_api_key_with_manage_api_perm
9194 ):
9295 """Templates from other services must not be accessible."""
96+ other_service = create_service (service_name = f"other service { uuid .uuid4 ()} " )
97+ other_template = create_template (other_service , template_type = SMS_TYPE )
9398 auth_header = _auth_header (create_api_key_with_manage_api_perm )
9499
95100 response = client .get (
96- f"/v3/template/{ sample_template .id } " ,
101+ f"/v3/template/{ other_template .id } " ,
97102 headers = [("Content-Type" , "application/json" ), auth_header ],
98103 )
99104
100- # sample_template belongs to sample_service so this should work;
101- # if services differ the DAO raises NoResultFound → 404
102- # This test just verifies service scoping is enforced.
103- assert response .status_code in (200 , 404 )
105+ assert response .status_code == 404
104106
105107 def test_get_sms_template_has_null_subject (self , client , sample_service , create_api_key_with_manage_api_perm ):
106108 template = create_template (sample_service , template_type = SMS_TYPE )
0 commit comments