Skip to content

Commit 5fac7cf

Browse files
committed
Fix integration tests on TAS 6
TAS has a specific line of UAA releases 77.20.x, where x >= 8. The latest OSS release of that line is <a href="https://github.com/cloudfoundry/uaa/releases/v77.20.7">v77.20.7</a>. In those proprietary releases, the UAA info response has extra properties and crashes some tests. We do not want to include those extra fields into the OSS releases of CF-java-client. To have our integration tests succeed, we exclude these specific UAA releases.
1 parent 8566cea commit 5fac7cf

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

integration-test/src/test/java/org/cloudfoundry/uaa/ServerInformationTest.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,20 @@
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
2020

21+
import com.fasterxml.jackson.core.JsonProcessingException;
22+
import com.fasterxml.jackson.databind.ObjectMapper;
2123
import java.time.Duration;
2224
import java.util.function.Consumer;
2325
import org.cloudfoundry.AbstractIntegrationTest;
26+
import org.cloudfoundry.reactor.ConnectionContext;
2427
import org.cloudfoundry.uaa.serverinformation.AutoLoginRequest;
2528
import org.cloudfoundry.uaa.serverinformation.GetAutoLoginAuthenticationCodeRequest;
2629
import org.cloudfoundry.uaa.serverinformation.GetAutoLoginAuthenticationCodeResponse;
2730
import org.cloudfoundry.uaa.serverinformation.GetInfoRequest;
2831
import org.junit.jupiter.api.Test;
32+
import org.junit.jupiter.api.condition.DisabledIf;
2933
import org.springframework.beans.factory.annotation.Autowired;
34+
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
3035
import reactor.core.publisher.Mono;
3136
import reactor.test.StepVerifier;
3237

@@ -42,6 +47,8 @@ public final class ServerInformationTest extends AbstractIntegrationTest {
4247

4348
@Autowired private String username;
4449

50+
@Autowired private ConnectionContext context;
51+
4552
@Test
4653
public void autoLogin() {
4754
getAuthenticationCode(
@@ -83,6 +90,7 @@ public void getAutoLoginAuthenticationCode() {
8390
}
8491

8592
@Test
93+
@DisabledIf(value = "tasSpecificUaaVersion")
8694
public void getInfo() {
8795
this.uaaClient
8896
.serverInformation()
@@ -124,4 +132,46 @@ private static Mono<GetAutoLoginAuthenticationCodeResponse> requestAuthenticatio
124132
.username(username)
125133
.build());
126134
}
135+
136+
/**
137+
* TAS has a specific line of UAA releases 77.20.x, where x >= 8.
138+
* The latest OSS release of that line is <a href="https://github.com/cloudfoundry/uaa/releases/v77.20.7">v77.20.7</a>.
139+
* In those proprietary releases, the UAA info response has extra properties and crashes some tests.
140+
* We do not want to include those extra fields into the OSS releases of CF-java-client. To have our
141+
* integration tests succeed, we exclude these specific UAA releases.
142+
*/
143+
private boolean tasSpecificUaaVersion() {
144+
ObjectMapper mapper = Jackson2ObjectMapperBuilder.json().build();
145+
146+
Boolean hasTasSpecificUaaVersion =
147+
context.getRootProvider()
148+
.getRoot("uaa", context)
149+
.map(url -> context.getHttpClient().baseUrl(url))
150+
.flatMap(
151+
client ->
152+
client.get()
153+
.uri("/info")
154+
.responseContent()
155+
.aggregate()
156+
.asString())
157+
.map(
158+
r -> {
159+
try {
160+
return mapper.readTree(r).at("/app/version").asText();
161+
} catch (JsonProcessingException e) {
162+
throw new RuntimeException("Can't parse");
163+
}
164+
})
165+
.map(
166+
version -> {
167+
String[] versionParts = version.split("\\.");
168+
int major = Integer.parseInt(versionParts[0]);
169+
int minor = Integer.parseInt(versionParts[1]);
170+
int patch = Integer.parseInt(versionParts[2]);
171+
return major == 77 && minor == 20 && patch > 8;
172+
})
173+
.onErrorReturn(false)
174+
.block();
175+
return Boolean.TRUE.equals(hasTasSpecificUaaVersion);
176+
}
127177
}

0 commit comments

Comments
 (0)