-
Notifications
You must be signed in to change notification settings - Fork 280
fix(gdch): support EC private keys #1896
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
Changes from 58 commits
dc5b79c
0c5e423
5851b3e
258ac9d
e8511bb
a4d0f93
e3d5302
e6635c6
cc49dba
f58f593
42f2662
91a3751
b83a511
625741e
1e0a7c3
24cd25d
027a242
a8b459b
4e8af24
f257a81
c523df2
ed026a4
1528e76
7300e59
382d8ae
c348ee1
6323455
1aa7715
4f69872
f4b53ee
b3085a2
39ef931
3003076
36b7fa4
6805756
212cb89
8f23285
90fe11d
dcd97cb
1c5e7bb
571c9ac
6d713fe
d005709
0aa9ab9
3fe0ca5
06982d4
bd7af8d
583378e
5f59678
8fefc7b
fa51f57
f0873d3
66f8342
5ec685d
4c75b1d
6980520
d0547e3
00ff824
a57def2
0465e2c
a885a94
3d84edf
e0ae1c1
1d02562
7d3458f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,7 +83,8 @@ class DefaultCredentialsProviderTest { | |
| private static final String SA_PRIVATE_KEY_ID = "d84a4fefcf50791d4a90f2d7af17469d6282df9d"; | ||
| private static final String SA_PRIVATE_KEY_PKCS8 = | ||
| ServiceAccountCredentialsTest.PRIVATE_KEY_PKCS8; | ||
| private static final String GDCH_SA_FORMAT_VERSION = GdchCredentials.SUPPORTED_FORMAT_VERSION; | ||
| private static final String GDCH_SA_FORMAT_VERSION = | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can the tests just use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, done. |
||
| GdchCredentials.SUPPORTED_JSON_FORMAT_VERSION; | ||
| private static final String GDCH_SA_PROJECT_ID = "gdch-service-account-project-id"; | ||
| private static final String GDCH_SA_PRIVATE_KEY_ID = "d84a4fefcf50791d4a90f2d7af17469d6282df9d"; | ||
| private static final String GDCH_SA_PRIVATE_KEY_PKC8 = GdchCredentialsTest.PRIVATE_KEY_PKCS8; | ||
|
|
@@ -94,7 +95,7 @@ class DefaultCredentialsProviderTest { | |
| private static final String GDCH_SA_CA_CERT_FILE_NAME = "cert.pem"; | ||
| private static final String GDCH_SA_CA_CERT_PATH = | ||
| GdchCredentialsTest.class.getClassLoader().getResource(GDCH_SA_CA_CERT_FILE_NAME).getPath(); | ||
| private static final URI GDCH_SA_API_AUDIENCE = URI.create("https://gdch-api-audience"); | ||
| private static final String GDCH_SA_API_AUDIENCE = "https://gdch-api-audience"; | ||
| private static final Collection<String> SCOPES = Collections.singletonList("dummy.scope"); | ||
| private static final URI CALL_URI = URI.create("http://googleapis.com/testapi/v1/foo"); | ||
| private static final String QUOTA_PROJECT = "sample-quota-project-id"; | ||
|
|
@@ -180,48 +181,33 @@ void getDefaultCredentials_noCredentials_singleGceTestRequest() { | |
| } | ||
|
|
||
| @Test | ||
| void getDefaultCredentials_noCredentials_linuxNotGce() throws IOException { | ||
| TestDefaultCredentialsProvider testProvider = new TestDefaultCredentialsProvider(); | ||
| testProvider.setProperty("os.name", "Linux"); | ||
| String productFilePath = SMBIOS_PATH_LINUX; | ||
| InputStream productStream = new ByteArrayInputStream("test".getBytes()); | ||
| testProvider.addFile(productFilePath, productStream); | ||
|
|
||
| assertFalse(ComputeEngineCredentials.checkStaticGceDetection(testProvider)); | ||
| void getDefaultCredentials_noCredentials_linuxNotGce() { | ||
| checkStaticGceDetection("linux", "test", false); | ||
| } | ||
|
|
||
| @Test | ||
| void getDefaultCredentials_static_linux() throws IOException { | ||
| TestDefaultCredentialsProvider testProvider = new TestDefaultCredentialsProvider(); | ||
| testProvider.setProperty("os.name", "Linux"); | ||
| String productFilePath = SMBIOS_PATH_LINUX; | ||
| File productFile = new File(productFilePath); | ||
| InputStream productStream = new ByteArrayInputStream("Googlekdjsfhg".getBytes()); | ||
| testProvider.addFile(productFile.getAbsolutePath(), productStream); | ||
|
|
||
| assertTrue(ComputeEngineCredentials.checkStaticGceDetection(testProvider)); | ||
| void getDefaultCredentials_static_linux() { | ||
| checkStaticGceDetection("linux", "Googlekdjsfhg", true); | ||
| } | ||
|
|
||
| @Test | ||
| void getDefaultCredentials_static_windows_configuredAsLinux_notGce() throws IOException { | ||
| TestDefaultCredentialsProvider testProvider = new TestDefaultCredentialsProvider(); | ||
| testProvider.setProperty("os.name", "windows"); | ||
| String productFilePath = SMBIOS_PATH_LINUX; | ||
| InputStream productStream = new ByteArrayInputStream("Googlekdjsfhg".getBytes()); | ||
| testProvider.addFile(productFilePath, productStream); | ||
|
|
||
| assertFalse(ComputeEngineCredentials.checkStaticGceDetection(testProvider)); | ||
| void getDefaultCredentials_static_windows_configuredAsLinux_notGce() { | ||
| checkStaticGceDetection("windows", "Googlekdjsfhg", false); | ||
| } | ||
|
|
||
| @Test | ||
| void getDefaultCredentials_static_unsupportedPlatform_notGce() throws IOException { | ||
| void getDefaultCredentials_static_unsupportedPlatform_notGce() { | ||
| checkStaticGceDetection("macos", "Googlekdjsfhg", false); | ||
| } | ||
|
|
||
| private void checkStaticGceDetection(String osName, String productContent, boolean expected) { | ||
| TestDefaultCredentialsProvider testProvider = new TestDefaultCredentialsProvider(); | ||
| testProvider.setProperty("os.name", "macos"); | ||
| testProvider.setProperty("os.name", osName); | ||
| String productFilePath = SMBIOS_PATH_LINUX; | ||
| InputStream productStream = new ByteArrayInputStream("Googlekdjsfhg".getBytes()); | ||
| InputStream productStream = new ByteArrayInputStream(productContent.getBytes()); | ||
| testProvider.addFile(productFilePath, productStream); | ||
|
|
||
| assertFalse(ComputeEngineCredentials.checkStaticGceDetection(testProvider)); | ||
| assertEquals(expected, ComputeEngineCredentials.checkStaticGceDetection(testProvider)); | ||
| } | ||
|
|
||
| @Test | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.