Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 pkg/apis/application/v1alpha1/app_project_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ func (proj AppProject) isDestinationMatched(dst ApplicationDestination) bool {
switch {
case matched:
anyDestinationMatched = true
case (!dstNameMatched && isDenyPattern(item.Name)) || (!dstServerMatched && isDenyPattern(item.Server)) && dstNamespaceMatched:
case ((!dstNameMatched && isDenyPattern(item.Name)) || (!dstServerMatched && isDenyPattern(item.Server))) && dstNamespaceMatched:
return false
case !dstNamespaceMatched && isDenyPattern(item.Namespace) && dstServerMatched:
return false
Expand Down
18 changes: 18 additions & 0 deletions pkg/apis/application/v1alpha1/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,24 @@ func TestAppProject_IsNegatedDestinationPermitted(t *testing.T) {
}},
appDest: ApplicationDestination{Server: "https://other-test-server", Namespace: "other"},
isPermitted: true,
}, {
// Name deny pattern should NOT apply when namespace doesn't match (regression test for operator precedence fix)
projDest: []ApplicationDestination{{
Name: "*", Namespace: "*",
}, {
Name: "!bad", Namespace: "other",
}},
appDest: ApplicationDestination{Name: "bad", Namespace: "test"},
isPermitted: true,
}, {
// Name deny pattern should apply when namespace matches
projDest: []ApplicationDestination{{
Name: "*", Namespace: "*",
}, {
Name: "!bad", Namespace: "test",
}},
appDest: ApplicationDestination{Name: "bad", Namespace: "test"},
isPermitted: false,
}}

for _, data := range testData {
Expand Down
Loading