From dd84ca6ea92567eeaed3ed2bae702de822fd9585 Mon Sep 17 00:00:00 2001 From: Zbynek Konecny Date: Thu, 18 Sep 2025 02:54:06 +0200 Subject: [PATCH] Update gitlab-api dependency --- pom.xml | 19 ++++++++ .../plugins/GitLabAuthenticationToken.java | 2 +- .../plugins/GitLabSecurityRealm.java | 2 +- .../GitLabAuthenticationTokenTest.java | 44 +++++++++++++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 src/test/java/org/jenkinsci/plugins/GitLabAuthenticationTokenTest.java diff --git a/pom.xml b/pom.xml index d093fcd..6ab4f3f 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,10 @@ repo.jenkins-ci.org https://repo.jenkins-ci.org/public/ + + incrementals + https://repo.jenkins-ci.org/incrementals/ + @@ -89,6 +93,12 @@ io.jenkins.plugins gitlab-api + 6.1.0-106.v6c0b_5b_df4ee6 + + + io.jenkins.plugins + jakarta-xml-bind-api + 4.0.5-3.v3d5b_a_73965b_9 org.jenkins-ci.plugins @@ -97,6 +107,7 @@ org.jenkins-ci.plugins jackson2-api + 2.20.0-417.va_5311a_823a_b_8 @@ -276,6 +287,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + diff --git a/src/main/java/org/jenkinsci/plugins/GitLabAuthenticationToken.java b/src/main/java/org/jenkinsci/plugins/GitLabAuthenticationToken.java index 3872548..cf474a4 100755 --- a/src/main/java/org/jenkinsci/plugins/GitLabAuthenticationToken.java +++ b/src/main/java/org/jenkinsci/plugins/GitLabAuthenticationToken.java @@ -43,12 +43,12 @@ of this software and associated documentation files (the "Software"), to deal import jenkins.model.Jenkins; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; -import org.gitlab4j.api.Constants.TokenType; import org.gitlab4j.api.GitLabApi; import org.gitlab4j.api.GitLabApiException; import org.gitlab4j.api.models.Group; import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.User; +import org.gitlab4j.models.Constants.TokenType; import org.springframework.security.authentication.AbstractAuthenticationToken; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; diff --git a/src/main/java/org/jenkinsci/plugins/GitLabSecurityRealm.java b/src/main/java/org/jenkinsci/plugins/GitLabSecurityRealm.java index 007c164..5dcc2af 100644 --- a/src/main/java/org/jenkinsci/plugins/GitLabSecurityRealm.java +++ b/src/main/java/org/jenkinsci/plugins/GitLabSecurityRealm.java @@ -72,9 +72,9 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; -import org.gitlab4j.api.Constants.TokenType; import org.gitlab4j.api.GitLabApiException; import org.gitlab4j.api.models.Group; +import org.gitlab4j.models.Constants.TokenType; import org.jfree.util.Log; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.Header; diff --git a/src/test/java/org/jenkinsci/plugins/GitLabAuthenticationTokenTest.java b/src/test/java/org/jenkinsci/plugins/GitLabAuthenticationTokenTest.java new file mode 100644 index 0000000..03afbe5 --- /dev/null +++ b/src/test/java/org/jenkinsci/plugins/GitLabAuthenticationTokenTest.java @@ -0,0 +1,44 @@ +/* + The MIT License + + Copyright (c) 2025 Jenkins contributors + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +package org.jenkinsci.plugins; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.gitlab4j.api.GitLabApiException; +import org.gitlab4j.models.Constants; +import org.junit.jupiter.api.Test; + +public class GitLabAuthenticationTokenTest { + + /** + * This checks that we get the correct exception. + */ + @Test + public void testInvalidUrl() { + assertThrows(GitLabApiException.class, + () -> new GitLabAuthenticationToken("42", + "http://localhost/_invalid_url", Constants.TokenType.ACCESS)); + } +}