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

Numeric comparison assertion methods fail to compare non-integer values #436

Closed
BernieWhite opened this issue Mar 3, 2020 · 0 comments · Fixed by #447
Closed

Numeric comparison assertion methods fail to compare non-integer values #436

BernieWhite opened this issue Mar 3, 2020 · 0 comments · Fixed by #447
Assignees
Labels
bug Something isn't working
Milestone

Comments

@BernieWhite
Copy link
Member

BernieWhite commented Mar 3, 2020

Description of the issue

Numeric comparison assertion methods are unable to compare non-int values such as long and float.

JSON.Net uses Int64 when de-serializing a integer like numeric.

To Reproduce

Rule 'Azure.AppGw.MinInstance' -Type 'Microsoft.Network/applicationGateways' -Tag @{ release = 'GA' } {
    AnyOf {
        # Applies to v1 and v2 without autoscale
        $Assert.GreaterOrEqual($TargetObject, 'Properties.sku.capacity', 2);

        # Applies to v2 with autoscale
        $Assert.GreaterOrEqual($TargetObject, 'Properties.autoscaleConfiguration.minCapacity', 2);
    }
}

Should produce the same result as:

Rule 'Azure.AppGw.MinInstance' -Type 'Microsoft.Network/applicationGateways' -Tag @{ release = 'GA' } {
    AnyOf {
        # Applies to v1 and v2 without autoscale
        $TargetObject.Properties.sku.capacity -ge 2

        # Applies to v2 with autoscale
        $TargetObject.Properties.autoscaleConfiguration.minCapacity -ge 2
    }
}

Module in use and version:

  • Module: PSRule
  • Version: 0.15.0

Captured output from $PSVersionTable:

Name                           Value
----                           -----
PSVersion                      6.2.4
PSEdition                      Core
GitCommitId                    6.2.4
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
@BernieWhite BernieWhite added the bug Something isn't working label Mar 3, 2020
@BernieWhite BernieWhite added this to the v0.16.0 milestone Mar 5, 2020
@BernieWhite BernieWhite changed the title Incorrect handling of assert statements in AnyOf block Numeric comparison assertion methods fail to compare long Mar 22, 2020
@BernieWhite BernieWhite changed the title Numeric comparison assertion methods fail to compare long Numeric comparison assertion methods fail to compare non-integer values Mar 22, 2020
@BernieWhite BernieWhite self-assigned this Mar 22, 2020
@BernieWhite BernieWhite mentioned this issue Apr 1, 2020
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant