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

fix #465: user+pass auth url incorrect if API version specified in URL #520

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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