Skip to content

Commit 3101a02

Browse files
authored
Add windows Kokoro test config (#181)
* Add windows Kokoro test config * Fix location of build.bat * Fix windows working directory * Fix bath to build script * Use a tempfile for test files to avoid windows path issues * empty commit to trigger travis * Skip creating the temporary test json files. The actual file is not necessary for the tests - we only need a valid path for the OS. * Fix joining of paths * Fix osx script
1 parent 42c9906 commit 3101a02

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

.kokoro/build.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:: See documentation in type-shell-output.bat
2+
3+
"C:\Program Files\Git\bin\bash.exe" github/google-auth-library-java/.kokoro/build.sh

.kokoro/presubmit/java8-osx.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
build_file: "google-auth-library-java/.kokoro/build.sh"

.kokoro/presubmit/java8-win.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
build_file: "google-auth-library-java/.kokoro/build.bat"

oauth2_http/javatests/com/google/auth/oauth2/DefaultCredentialsProviderTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import java.io.IOException;
5454
import java.io.InputStream;
5555
import java.net.URI;
56+
import java.nio.file.Paths;
5657
import java.security.AccessControlException;
5758
import java.util.Collection;
5859
import java.util.Collections;
@@ -136,7 +137,7 @@ public void getDefaultCredentials_envValidSandbox_throwsNonSecurity() throws Exc
136137
UserCredentialsTest.writeUserStream(USER_CLIENT_ID, USER_CLIENT_SECRET, REFRESH_TOKEN);
137138
TestDefaultCredentialsProvider testProvider = new TestDefaultCredentialsProvider();
138139
testProvider.setFileSandbox(true);
139-
String userPath = "/user.json";
140+
String userPath = tempFilePath("user.json");
140141
testProvider.addFile(userPath, userStream);
141142
testProvider.setEnv(DefaultCredentialsProvider.CREDENTIAL_ENV_VAR, userPath);
142143

@@ -300,7 +301,7 @@ public void getDefaultCredentials_envServiceAccount_providesToken() throws IOExc
300301
.writeServiceAccountStream(
301302
SA_CLIENT_ID, SA_CLIENT_EMAIL, SA_PRIVATE_KEY_PKCS8, SA_PRIVATE_KEY_ID);
302303
TestDefaultCredentialsProvider testProvider = new TestDefaultCredentialsProvider();
303-
String serviceAccountPath = "/service_account.json";
304+
String serviceAccountPath = tempFilePath("service_account.json");
304305
testProvider.addFile(serviceAccountPath, serviceAccountStream);
305306
testProvider.setEnv(
306307
DefaultCredentialsProvider.CREDENTIAL_ENV_VAR, serviceAccountPath);
@@ -318,7 +319,7 @@ public void getDefaultCredentials_envUser_providesToken() throws IOException {
318319
InputStream userStream =
319320
UserCredentialsTest.writeUserStream(USER_CLIENT_ID, USER_CLIENT_SECRET, REFRESH_TOKEN);
320321
TestDefaultCredentialsProvider testProvider = new TestDefaultCredentialsProvider();
321-
String userPath = "/user.json";
322+
String userPath = tempFilePath("user.json");
322323
testProvider.addFile(userPath, userStream);
323324
testProvider.setEnv(DefaultCredentialsProvider.CREDENTIAL_ENV_VAR, userPath);
324325

@@ -420,7 +421,7 @@ public void getDefaultCredentials_envAndWellKnownFile_envPrecedence() throws IOE
420421

421422
InputStream envStream =
422423
UserCredentialsTest.writeUserStream(USER_CLIENT_ID, USER_CLIENT_SECRET, refreshTokenEnv);
423-
String envPath = "/env.json";
424+
String envPath = tempFilePath("env.json");
424425
testProvider.setEnv(DefaultCredentialsProvider.CREDENTIAL_ENV_VAR, envPath);
425426
testProvider.addFile(envPath, envStream);
426427

@@ -443,6 +444,10 @@ public void getDefaultCredentials_envAndWellKnownFile_envPrecedence() throws IOE
443444
testUserProvidesToken(testProvider, transportFactory, accessTokenEnv);
444445
}
445446

447+
private String tempFilePath(String filename) {
448+
return Paths.get(System.getProperty("java.io.tmpdir"), filename).toString();
449+
}
450+
446451
private class LogHandler extends Handler {
447452
LogRecord lastRecord;
448453

0 commit comments

Comments
 (0)