Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MoChilia committed Nov 27, 2023
1 parent bdbe715 commit 31435a1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 9 deletions.
33 changes: 32 additions & 1 deletion .github/workflows/azure-login-negative.yml
Expand Up @@ -352,7 +352,7 @@ jobs:
run: |
az logout
# SP1 is ignored and SP2 will be used for login, but it will failed since SP2 has no access to the given subscription
# SP1 is ignored and SP2 will be used for login, but it will fail since SP2 has no access to the given subscription
- name: Login with both creds and individual parameters
id: login_12
continue-on-error: true
Expand Down Expand Up @@ -387,6 +387,37 @@ jobs:
with:
script: |
core.setFailed('Last action should fail but not. Please check it.')
- name: Login with individual parameters, no subscription-id, no allow-no-subscriptions
id: login_14
continue-on-error: true
uses: ./
with:
client-id: ${{ secrets.OIDC_SP2_CLIENT_ID }}
tenant-id: ${{ secrets.OIDC_SP2_TENANT_ID }}
enable-AzPSSession: true

- name: Check Last step failed
if: steps.login_14.outcome == 'success'
uses: actions/github-script@v3
with:
script: |
core.setFailed('Last action should fail but not. Please check it.')
- name: Login with creds, no subscription-id, no allow-no-subscriptions
id: login_15
continue-on-error: true
uses: ./
with:
creds: '{"clientId":"${{ secrets.OIDC_SP2_CLIENT_ID }}","clientSecret":"${{ secrets.SP2_CLIENT_SECRET }}","tenantId":"${{ secrets.OIDC_SP2_TENANT_ID }}"}'
enable-AzPSSession: true

- name: Check Last step failed
if: steps.login_15.outcome == 'success'
uses: actions/github-script@v3
with:
script: |
core.setFailed('Last action should fail but not. Please check it.')
VMTest:
strategy:
Expand Down
30 changes: 26 additions & 4 deletions .github/workflows/azure-login-positive.yml
Expand Up @@ -61,10 +61,9 @@ jobs:
- name: Login with individual parameters
uses: ./
with:
client-id: ${{ secrets.OIDC_SP2_CLIENT_ID }}
tenant-id: ${{ secrets.OIDC_SP2_TENANT_ID }}
# subscription-id: ${{ secrets.OIDC_SP2_SUBSCRIPTION_ID }}
allow-no-subscriptions: true
client-id: ${{ secrets.SP1_CLIENT_ID }}
tenant-id: ${{ secrets.SP1_TENANT_ID }}
subscription-id: ${{ secrets.SP1_SUBSCRIPTION_ID }}
enable-AzPSSession: true

- name: Run Azure Cli again
Expand Down Expand Up @@ -176,6 +175,29 @@ jobs:
throw "Not all checks passed!"
}
- name: Login with individual parameters, allow no subscription
uses: ./
with:
client-id: ${{ secrets.OIDC_SP2_CLIENT_ID }}
tenant-id: ${{ secrets.OIDC_SP2_TENANT_ID}}
subscription-id: ${{ secrets.OIDC_SP2_TENANT_ID }}
allow-no-subscriptions: true
enable-AzPSSession: true

- name: Run Azure Cli again
run: |
az account show --output none
- name: Run Azure PowerShell again
uses: azure/powershell@v1.2.0
with:
azPSVersion: "latest"
inlineScript: |
$checkResult = (Get-AzContext).Environment.Name -eq 'AzureCloud'
if(-not $checkResult){
throw "Not all checks passed!"
}
- name: Login with individual parameters, no subscription, allow no subscription
uses: ./
with:
Expand Down
6 changes: 2 additions & 4 deletions __tests__/LoginConfig.test.ts
Expand Up @@ -74,9 +74,8 @@ describe("LoginConfig Test", () => {
await testCreds(creds1);

});


test('initialize with creds, lack of subscriptionId, but allowNoSubscriptionsLogin=true', async () => {

test('initialize with creds, lack of subscriptionId, but allowNoSubscriptionsLogin=true', async () => {
let creds1 = {
'clientId': 'client-id',
'clientSecret': 'client-secret',
Expand All @@ -100,7 +99,6 @@ describe("LoginConfig Test", () => {
expect(loginConfig.subscriptionId).toBe("");
});


test('initialize with creds', async () => {
let creds = {
'clientId': 'client-id',
Expand Down

0 comments on commit 31435a1

Please sign in to comment.