Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.apache.http.client.HttpResponseException: status code: 403, reason phrase: Forbidden #434

Open
wants to merge 12 commits into
base: PR-392
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [khmarbaise]
20 changes: 20 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=8.0.252.hs-adpt
10 changes: 10 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## Release 0.4.0 (NOT RELEASED YET)

* [Fixed Issue 465][issue-465]

* Remove asciidoctor site parts
* AS preparation for user guide.

* [Fixed Issue 464][issue-464]

* Replaced xml-apis with xerces-xmlParserAPI.

* [Fixed Issue 309][issue-309]

* Added possibility to get mode detailed data from Maven Modules from Jobs/Builds
Expand Down Expand Up @@ -1156,6 +1165,7 @@ TestReport testReport = mavenJob.getLastSuccessfulBuild().getTestReport();
[issue-401]: https://github.com/jenkinsci/java-client-api/issues/401
[issue-402]: https://github.com/jenkinsci/java-client-api/issues/402
[issue-405]: https://github.com/jenkinsci/java-client-api/issues/405
[issue-464]: https://github.com/jenkinsci/java-client-api/issues/464
[pull-123]: https://github.com/jenkinsci/java-client-api/pull/123
[pull-149]: https://github.com/jenkinsci/java-client-api/pull/149
[pull-158]: https://github.com/jenkinsci/java-client-api/pull/158
Expand Down
7 changes: 3 additions & 4 deletions jenkins-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</dependency>

<dependency>
<groupId>dom4j</groupId>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>

Expand Down Expand Up @@ -109,10 +109,9 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<groupId>xerces</groupId>
<artifactId>xmlParserAPIs</artifactId>
</dependency>
</dependencies>

Expand Down
7 changes: 0 additions & 7 deletions jenkins-client/src/site/asciidoc/index.adoc

This file was deleted.

1 change: 0 additions & 1 deletion jenkins-client/src/site/asciidoc/sub/sub.adoc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
*/
package com.offbytwo.jenkins.client;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;

import java.io.ByteArrayInputStream;
import java.net.URI;
import org.apache.http.Header;
Expand All @@ -15,12 +21,7 @@
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.protocol.HttpContext;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;



Expand All @@ -30,7 +31,7 @@
*/
public class JenkinsHttpClientTest {
private static final String URI = "http://localhost/jenkins";



@Test
Expand All @@ -40,8 +41,8 @@ public void testGet_String() throws Exception {
final Header versionHeader = mock(Header.class);
final StatusLine statusLine = mock(StatusLine.class);
final HttpEntity entity = mock(HttpEntity.class);
given(client.execute(any(HttpUriRequest.class), any(HttpContext.class))).willReturn(response);
given(response.getHeaders(anyString())).willReturn(new Header[]{versionHeader});
given(client.execute(any(HttpUriRequest.class), eq((HttpContext)null))).willReturn(response);
given(response.getHeaders("X-Jenkins")).willReturn(new Header[]{versionHeader});
given(response.getStatusLine()).willReturn(statusLine);
given(versionHeader.getValue()).willReturn("1.234");
given(statusLine.getStatusCode()).willReturn(HttpStatus.SC_OK);
Expand All @@ -51,15 +52,15 @@ public void testGet_String() throws Exception {
final String s = jclient.get("job/someJob");
assertEquals("someJson", s);
}



@Test(expected=IllegalStateException.class)
public void testClose() throws Exception {
final JenkinsHttpConnection jclient = new JenkinsHttpClient(new URI(URI));
jclient.close();
jclient.close(); //check multiple calls yield no errors
jclient.get("job/someJob");
jclient.get("job/someJob");
}


Expand Down
91 changes: 35 additions & 56 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,20 @@
<maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
<maven.compiler.showWarnings>true</maven.compiler.showWarnings>

<asciidoctor-maven-plugin.version>1.5.3</asciidoctor-maven-plugin.version>
<asciidoctor-maven-plugin.version>2.0.0</asciidoctor-maven-plugin.version>

<!-- Version of Jenkins to use for Integration Tests -->
<jenkins-version>1.644</jenkins-version>
<junit.version>4.12</junit.version>
<mockito-core.version>1.9.5</mockito-core.version>
<mockito-core.version>3.0.0</mockito-core.version>
<commons-io.version>2.4</commons-io.version>
<xstream.version>1.4.7-jenkins-1</xstream.version>
<dom4j.version>1.6.1</dom4j.version>
<commons-lang.version>3.8.1</commons-lang.version>
<commons-lang.version>3.9</commons-lang.version>
<json-lib.version>2.4</json-lib.version>
<httpclient.version>4.5.8</httpclient.version>
<httpcore.version>4.4.11</httpcore.version>
<httpmime.version>4.5.8</httpmime.version>
<jackson-databind.version>2.9.8</jackson-databind.version>
<jackson-databind.version>2.10.3</jackson-databind.version>
</properties>

<licenses>
Expand Down Expand Up @@ -105,9 +104,9 @@
</dependency>

<dependency>
<groupId>dom4j</groupId>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>${dom4j.version}</version>
<version>2.1.3</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -165,34 +164,36 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.2</version>
<scope>test</scope>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.5.2</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito-core.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-test-harness</artifactId>
<version>${jenkins-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.12.2</version>
<scope>test</scope>
</dependency>

<dependency>
Expand All @@ -202,18 +203,15 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.1</version>
<artifactId>log4j-bom</artifactId>
<version>2.12.1</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.11.1</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
<groupId>xerces</groupId>
<artifactId>xmlParserAPIs</artifactId>
<version>2.6.1</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand All @@ -224,7 +222,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>3.1.1</version>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -239,7 +237,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<executions>
<!--
! here we override the super-pom attach-sources execution id which
Expand All @@ -256,27 +254,27 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.1</version>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.22.1</version>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<version>3.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<version>3.1.2</version>
<configuration>
<archive>
<manifest>
Expand All @@ -289,7 +287,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.8.1</version>
</plugin>
<!--
! We define a newer version than in parent.
Expand All @@ -302,12 +300,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<version>3.0.0-M1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<version>3.0.0-M1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -340,12 +338,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
<version>3.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -362,28 +360,9 @@
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-module-markdown</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>${asciidoctor-maven-plugin.version}</version>
<version>1.9</version>
</dependency>
</dependencies>
<configuration>
<asciidoc>
<!-- optional site-wide AsciiDoc attributes -->
<attributes>
<icons>font</icons>
<source-highlighter>coderay</source-highlighter>
<coderay-css>style</coderay-css>
<toclevels>2</toclevels>
<project-version>${project.version}</project-version>
<sectnums>true</sectnums>
<preserveDirectories>true</preserveDirectories>
</attributes>
</asciidoc>
</configuration>
</plugin>
</plugins>
</build>
Expand Down Expand Up @@ -479,7 +458,7 @@
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

Expand Down