-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Packages impacted by this PR @azure/identity ### Issues associated with this PR Contributes to #26434 ### Describe the problem that is addressed by this PR Adds AKS managed identity integration tests
- Loading branch information
Showing
15 changed files
with
285 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
src/**/*.js | ||
integration/AzureFunctions/app.zip | ||
integration/AzureWebApps/.azure/ | ||
integration/kubeconfig.yaml | ||
!assets/fake-cert.pem | ||
!assets/fake-cert-password.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
sdk/identity/identity/integration/AzureKubernetes/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
const { BlobServiceClient } = require("@azure/storage-blob"); | ||
const { ManagedIdentityCredential, WorkloadIdentityCredential } = require("@azure/identity"); | ||
|
||
async function main() { | ||
const storageAccount = process.env.IDENTITY_STORAGE_NAME_2; | ||
if (!storageAccount) { | ||
throw new Error("Missing IDENTITY_STORAGE_NAME_2 env var"); | ||
} | ||
|
||
const clientId = process.env.IDENTITY_USER_DEFINED_CLIENT_ID; | ||
if (!clientId) { | ||
throw new Error("Missing IDENTITY_USER_DEFINED_CLIENT_ID env var"); | ||
} | ||
|
||
const blobUrl = `https://${storageAccount}.blob.core.windows.net`; | ||
|
||
try { | ||
const blobServiceClient = new BlobServiceClient( | ||
blobUrl, | ||
new ManagedIdentityCredential({ | ||
clientId, | ||
}), | ||
); | ||
await blobServiceClient.getProperties(); | ||
|
||
// The test looks for this line in the output | ||
console.log("ManagedIdentity: Successfully authenticated with storage"); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
|
||
try { | ||
const blobServiceClient = new BlobServiceClient( | ||
blobUrl, | ||
new WorkloadIdentityCredential({ | ||
clientId, | ||
}), | ||
); | ||
await blobServiceClient.getProperties(); | ||
|
||
// The test looks for this line in the output | ||
console.log("WorkloadIdentity: Successfully authenticated with storage"); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} | ||
|
||
main().then(console.log).catch(console.error); |
31 changes: 11 additions & 20 deletions
31
sdk/identity/identity/integration/AzureKubernetes/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,13 @@ | ||
{ | ||
"name": "@azure-samples/azure-kubernetes-test", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"start": "ts-node src/index.ts", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@azure/identity": "^4.0.0", | ||
"@azure/storage-blob": "^12.17.0", | ||
"tslib": "^1.10.0", | ||
"ts-node": "10.9.2" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.3.3" | ||
} | ||
"name": "@azure-samples/azure-kubernetes-test", | ||
"version": "1.0.0", | ||
"description": "A simple node JS script that can be used to test MSI on Kubernetes", | ||
"main": "index.js", | ||
"scripts": {}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@azure/identity": "dev", | ||
"@azure/storage-blob": "^12.17.0" | ||
} | ||
} |
48 changes: 0 additions & 48 deletions
48
sdk/identity/identity/integration/AzureKubernetes/src/index.ts
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
sdk/identity/identity/integration/AzureKubernetes/tsconfig.json
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.