Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
exit 1
fi

if ! [[ "$PR_BRANCH" =~ ^(bug|feature|other)/ ]]; then
if ! [[ "$PR_BRANCH" =~ ^(bug|fix|feature|other)/ ]]; then
echo "::error::Branch name must start with 'bug/' or 'feature/' or 'other/'."
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Each line is a file pattern followed by one or more owners

# Specify the default owners for the entire repository
* @OrShamirCM @AlvoBen
* @AlvoBen @greensd4 @miryamfoiferCX
18 changes: 18 additions & 0 deletions internal/services/asca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

errorconstants "github.com/checkmarx/ast-cli/internal/constants/errors"
"github.com/checkmarx/ast-cli/internal/wrappers"
"github.com/checkmarx/ast-cli/internal/wrappers/grpcs"
"github.com/checkmarx/ast-cli/internal/wrappers/mock"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -130,3 +131,20 @@ func TestCreateASCAScanRequest_EngineRunningAndDefaultAgentAndNoLicense_Success(
assert.Nil(t, wrapperParams.ASCAWrapper.HealthCheck())
_ = wrapperParams.ASCAWrapper.ShutDown()
}

func TestCreateASCAScanRequest_CheckLicenseWhenPackageEnforcementFFOff_SuccessWithNilError(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to use the key words when, should

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this test name is obvious and according to our conventions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be something like:
TestCreateASCAScanRequest_whenCheckLicenseWithPackageEnforcementFFOff_shouldSuccess

port, err := getAvailablePort()
if err != nil {
t.Fatalf("Failed to get available port: %v", err)
}

mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.PackageEnforcementEnabled, Status: false}

wrapperParams := AscaWrappersParam{
JwtWrapper: wrappers.NewJwtWrapper(),
FeatureFlagsWrapper: &mock.FeatureFlagsMockWrapper{},
ASCAWrapper: grpcs.NewASCAGrpcWrapper(port),
}
err = checkLicense(false, wrapperParams)
assert.Nil(t, err)
}
3 changes: 2 additions & 1 deletion internal/wrappers/jwt-helper.go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe return
if !flagResponse.Status {
return true, nil
}
jwtStruct, err := getJwtStruct()...

Early return if the feature flag is disabled, to avoid unnecessary nested logic

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea!

Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ func (*JWTStruct) IsAllowedEngine(engine string, featureFlagsWrapper FeatureFlag
return true, nil
}
}
return false, nil
}
return false, nil
return true, nil
}

func prepareEngines(engines []string) map[string]bool {
Expand Down