Skip to content

Commit

Permalink
fix #465: user+pass auth url incorrect if API version specified in URL
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Oct 9, 2023
1 parent 62a8065 commit c7f12f5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ private static void buildFormAuth(
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
builder.cookieJar(new JavaNetCookieJar(cookieManager));


String postUrl = parse
String postUrl = HttpUrl.parse(appBaseUrl)
.newBuilder()
.addPathSegment(
System.getProperty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.rundeck.client

import org.rundeck.client.util.FormAuthInterceptor
import spock.lang.Specification

/**
Expand Down Expand Up @@ -50,6 +51,30 @@ class RundeckClientSpec extends Specification {
'https' | _
}

def "password auth with API vers has correct auth url"() {
given:
def root = 'https://example.com'
when:

def builder = RundeckClient.builder().
baseUrl(root + basePath).
passwordAuth('user1', 'pass1')

then:
builder.okhttp.interceptors().size() == 1
def formAuth = builder.okhttp.interceptors().get(0)
formAuth instanceof FormAuthInterceptor
formAuth.baseUrl == (root + expectedBase)
formAuth.j_security_url == (root + expectedSecurity)

where:
basePath | expectedBase | expectedSecurity
"/" | "/" | "/j_security_check"
"/api/19" | "/" | "/j_security_check"
"/context" | "/context/" | "/context/j_security_check"
"/context/api/19" | "/context/" | "/context/j_security_check"
}

def "create token valid"() {
given:
def token = 'abc'
Expand Down

0 comments on commit c7f12f5

Please sign in to comment.