Merge branch 'main' into avm99963-monorail

Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266

GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/tracker/test/issueentry_test.py b/tracker/test/issueentry_test.py
index b7461ae..b18f70b 100644
--- a/tracker/test/issueentry_test.py
+++ b/tracker/test/issueentry_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# Copyright 2016 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
 
 """Unittests for the issueentry servlet."""
 from __future__ import print_function
@@ -19,7 +18,6 @@
 
 from google.appengine.ext import testbed
 from mock import Mock, patch
-import webapp2
 
 from framework import framework_bizobj
 from framework import framework_views
@@ -30,8 +28,8 @@
 from testing import testing_helpers
 from tracker import issueentry
 from tracker import tracker_bizobj
-from proto import tracker_pb2
-from proto import user_pb2
+from mrproto import tracker_pb2
+from mrproto import user_pb2
 
 
 class IssueEntryTest(unittest.TestCase):
@@ -51,10 +49,7 @@
         template=Mock(spec=template_svc.TemplateService),
         features=fake.FeaturesService())
     self.project = self.services.project.TestAddProject('proj', project_id=987)
-    request = webapp2.Request.blank('/p/proj/issues/entry')
-    response = webapp2.Response()
-    self.servlet = issueentry.IssueEntry(
-        request, response, services=self.services)
+    self.servlet = issueentry.IssueEntry(services=self.services)
     self.user = self.services.user.TestAddUser('to_pass_tests', 0)
     self.services.features.TestAddHotlist(
         name='dontcare', summary='', owner_ids=[0])
@@ -752,6 +747,46 @@
     self.assertEqual(field_values[0].int_value, 3)
     self.assertEqual(field_values[1].int_value, 3737)
 
+  def testProcessFormData_RejectNewLabels(self):
+    """We raise an AssertionError when new labels are added."""
+    mr = testing_helpers.MakeMonorailRequest(path='/p/proj/issues/entry')
+    mr.perms = permissions.USER_PERMISSIONSET
+    mr.auth.user_view = framework_views.StuffUserView(100, 'user@invalid', True)
+    post_data = fake.PostData(
+        template_name=['rutabaga'],
+        summary=['Nya nya I modified the summary'],
+        comment=[self.template.content],
+        status=['New'],
+        label=['freeze_new_label'])
+
+    self.mox.StubOutWithMock(self.servlet, 'PleaseCorrect')
+    self.servlet.PleaseCorrect(
+        mr,
+        component_required=None,
+        fields=[],
+        initial_blocked_on='',
+        initial_blocking='',
+        initial_cc='',
+        initial_comment=self.template.content,
+        initial_components='',
+        initial_owner='',
+        initial_status='New',
+        initial_summary='Nya nya I modified the summary',
+        initial_hotlists='',
+        labels=['freeze_new_label'],
+        template_name='rutabaga')
+    self.mox.ReplayAll()
+    url = self.servlet.ProcessFormData(mr, post_data)
+    self.mox.VerifyAll()
+    self.assertEqual(
+        (
+            "The creation of new labels is blocked for the Chromium project"
+            " in Monorail. To continue with editing your issue, please"
+            " remove: freeze_new_label label(s)."),
+        mr.errors.labels,
+    )
+    self.assertIsNone(url)
+
   def testProcessFormData_RejectRestrictedFields(self):
     """We raise an AssertionError when restricted fields are set w/o perms."""
     mr = testing_helpers.MakeMonorailRequest(