33import org .junit .jupiter .api .Test ;
44import org .junit .jupiter .params .ParameterizedTest ;
55import org .junit .jupiter .params .provider .CsvSource ;
6+ import org .keycloak .gh .bot .labels .Kind ;
67import org .keycloak .gh .bot .labels .Status ;
78import org .kohsuke .github .GHIssue ;
89import org .kohsuke .github .GHLabel ;
@@ -102,6 +103,7 @@ void applyCveIdFromSecAlert_replacesTitleAndRemovesCveRequestLabel() throws Exce
102103
103104 verify (issue ).setTitle ("[CVE-2026-9999] XSS in admin console" );
104105 verify (issue ).removeLabels (Status .CVE_REQUEST .toLabel ());
106+ verify (issue ).addLabels (Kind .CVE .toLabel ());
105107 }
106108
107109 @ Test
@@ -116,6 +118,7 @@ void applyCveIdFromSecAlert_doesNotRemoveLabelWhenNotPresent() throws Exception
116118
117119 verify (issue ).setTitle ("[CVE-2026-9999] XSS in admin console" );
118120 verify (issue , never ()).removeLabels (Status .CVE_REQUEST .toLabel ());
121+ verify (issue ).addLabels (Kind .CVE .toLabel ());
119122 }
120123
121124 @ Test
@@ -128,6 +131,7 @@ void applyCveIdFromSecAlert_noOpWhenTitleDoesNotStartWithCveTbd() throws Excepti
128131
129132 verify (issue , never ()).setTitle (org .mockito .ArgumentMatchers .anyString ());
130133 verify (issue , never ()).removeLabels (org .mockito .ArgumentMatchers .any (String [].class ));
134+ verify (issue , never ()).addLabels (org .mockito .ArgumentMatchers .any (String [].class ));
131135 }
132136
133137 @ Test
@@ -145,5 +149,23 @@ void applyCveIdFromSecAlert_extractsCveFromBodyWhenNotInSubject() throws Excepti
145149
146150 verify (issue ).setTitle ("[CVE-2026-5555] SSRF vulnerability" );
147151 verify (issue ).removeLabels (Status .CVE_REQUEST .toLabel ());
152+ verify (issue ).addLabels (Kind .CVE .toLabel ());
153+ }
154+
155+ @ Test
156+ void applyCveIdFromSecAlert_doesNotAddCveKindWhenAlreadyPresent () throws Exception {
157+ GHIssue issue = mock (GHIssue .class );
158+ when (issue .getTitle ()).thenReturn ("[CVE-TBD] OIDC token leak" );
159+ when (issue .getNumber ()).thenReturn (77 );
160+
161+ GHLabel cveKindLabel = mock (GHLabel .class );
162+ when (cveKindLabel .getName ()).thenReturn (Kind .CVE .toLabel ());
163+ when (issue .getLabels ()).thenReturn (List .of (cveKindLabel ));
164+
165+ MailProcessor processor = new MailProcessor ();
166+ processor .applyCveIdFromSecAlert (issue , "CVE-2026-8888 OIDC token leak" , "body" );
167+
168+ verify (issue ).setTitle ("[CVE-2026-8888] OIDC token leak" );
169+ verify (issue , never ()).addLabels (Kind .CVE .toLabel ());
148170 }
149171}
0 commit comments