Skip to content
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

unreliable test: checkNoNewAccess should handle Terraform Plan correctly: #6534

Open
Hweinstock opened this issue Feb 7, 2025 · 0 comments

Comments

@Hweinstock
Copy link
Contributor

Test Details

  • Name of test: checkNoNewAccess should handle Terraform Plan correctly:
  • OS of failure: Mac
  • VSCode version of failure (minimum/insider/stable): minimum
  • Link to failing run: https://github.com/aws/aws-toolkit-vscode/actions/runs/13206848909/job/36871882448
  • Link to failing test:
    it('checkNoNewAccess should handle Terraform Plan correctly', async function () {
    const documentType = 'Terraform Plan'
    const policyType = 'Identity'
    const referenceDocument = '{"some": "reference"}'
    const document = 'path/to/terraform.json'
    const cfnParameterPath = 'path/to/cfn-params'
    sandbox.stub(IamPolicyChecksWebview, 'editedDocumentFileName').value(document)
    sandbox.stub(iamPolicyChecks, 'isTerraformPlan').returns(true)
    sandbox.stub(iamPolicyChecks, 'isCloudFormationTemplate').returns(false)
    executeCustomPolicyChecksCommandStub = sandbox.stub(fakePolicyChecksWebview, 'executeCustomPolicyChecksCommand')
    await fakePolicyChecksWebview.checkNoNewAccess(documentType, policyType, referenceDocument, cfnParameterPath)
    // We do not want to validate the path of the temporary folder, so we check every other field instead of the entire args
    assert(executeCustomPolicyChecksCommandStub.called)
    const actualCommand = executeCustomPolicyChecksCommandStub.getCalls()[0].args[0]
    assert.deepStrictEqual(actualCommand.command, 'tf-policy-validator')
    assert.deepStrictEqual(actualCommand.args[0], 'check-no-new-access')
    assert.deepStrictEqual(actualCommand.args[2], document)
    assert.deepStrictEqual(actualCommand.args[4], 'us-east-1')
    assert.deepStrictEqual(actualCommand.args[6], `${globals.context.asAbsolutePath(defaultTerraformConfigPath)}`)
    assert.deepStrictEqual(actualCommand.args[10], policyType)
    assert.deepStrictEqual(actualCommand.cfnParameterPathExists, true)
    assert.deepStrictEqual(actualCommand.documentType, documentType)
    assert.deepStrictEqual(actualCommand.checkType, 'CheckNoNewAccess')
    assert.deepStrictEqual(actualCommand.referencePolicyType, policyType)
    assert(onCustomPolicyCheckResponseFireSpy.notCalled)
    })

Log of Test Failure

checkNoNewAccess should handle Terraform Plan correctly:

      AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

  (0, assert_1.default)(executeCustomPolicyChecksCommandStub.called)

      + expected - actual

      -false
      +true

Additional Information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant