mirror of
https://github.com/azure/login.git
synced 2026-03-15 09:20:56 -04:00
Compare commits
2 Commits
ganeshrock
...
users/aksm
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
721fa655a7 | ||
|
|
3e0006684e |
@@ -5,7 +5,7 @@ jest.mock('../../src/PowerShell/Utilities/PowerShellToolRunner');
|
|||||||
let spnlogin: ServicePrincipalLogin;
|
let spnlogin: ServicePrincipalLogin;
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
spnlogin = new ServicePrincipalLogin("servicePrincipalID", "servicePrinicipalkey", "tenantId", "subscriptionId");
|
spnlogin = new ServicePrincipalLogin("servicePrincipalID", "servicePrinicipalkey", "tenantId", "subscriptionId", false);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
25
__tests__/PowerShell/Utilities/ScriptBuilder.test.ts
Normal file
25
__tests__/PowerShell/Utilities/ScriptBuilder.test.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import ScriptBuilder from "../../../src/PowerShell/Utilities/ScriptBuilder";
|
||||||
|
import Constants from "../../../src/PowerShell/Constants";
|
||||||
|
|
||||||
|
describe("Getting AzLogin PS script" , () => {
|
||||||
|
const scheme = Constants.ServicePrincipal;
|
||||||
|
let args: any = {
|
||||||
|
servicePrincipalId: "service-principal-id",
|
||||||
|
servicePrincipalKey: "service-principal-key",
|
||||||
|
environment: "environment",
|
||||||
|
scopeLevel: Constants.Subscription,
|
||||||
|
subscriptionId: "subId",
|
||||||
|
allowNoSubscriptionsLogin: true
|
||||||
|
}
|
||||||
|
|
||||||
|
test("PS script should not set context while passing allowNoSubscriptionsLogin as true", () => {
|
||||||
|
const loginScript = new ScriptBuilder().getAzPSLoginScript(scheme, "tenant-id", args);
|
||||||
|
expect(loginScript.includes("Set-AzContext -SubscriptionId")).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("PS script should set context while passing allowNoSubscriptionsLogin as false", () => {
|
||||||
|
args["allowNoSubscriptionsLogin"] = false;
|
||||||
|
const loginScript = new ScriptBuilder().getAzPSLoginScript(scheme, "tenant-id", args);
|
||||||
|
expect(loginScript.includes("Set-AzContext -SubscriptionId")).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -45,7 +45,6 @@ function main() {
|
|||||||
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
|
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
|
||||||
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
||||||
const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
|
const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
|
||||||
console.log(allowNoSubscriptionsLogin);
|
|
||||||
if (!servicePrincipalId || !servicePrincipalKey || !tenantId) {
|
if (!servicePrincipalId || !servicePrincipalKey || !tenantId) {
|
||||||
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret and tenantId are supplied.");
|
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret and tenantId are supplied.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ async function main() {
|
|||||||
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
|
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
|
||||||
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
||||||
const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
|
const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
|
||||||
console.log(allowNoSubscriptionsLogin);
|
|
||||||
if (!servicePrincipalId || !servicePrincipalKey || !tenantId) {
|
if (!servicePrincipalId || !servicePrincipalKey || !tenantId) {
|
||||||
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret and tenantId are supplied.");
|
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret and tenantId are supplied.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user