-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add app_protect_compressed_requests_action directive (#1643)
* add app_protect_compressed_requests_action directive * add tests for app-protect-compressed-requests-action Co-authored-by: galitskiy <[email protected]>
- Loading branch information
Showing
6 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package configs | ||
|
||
import ( | ||
"testing" | ||
|
||
v1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func TestParseConfigMapWithAppProtectCompressedRequestsAction(t *testing.T) { | ||
tests := []struct { | ||
action string | ||
expect string | ||
msg string | ||
}{ | ||
{ | ||
action: "pass", | ||
expect: "pass", | ||
msg: "valid action pass", | ||
}, | ||
{ | ||
action: "drop", | ||
expect: "drop", | ||
msg: "valid action drop", | ||
}, | ||
{ | ||
action: "invalid", | ||
expect: "", | ||
msg: "invalid action", | ||
}, | ||
{ | ||
action: "", | ||
expect: "", | ||
msg: "empty action", | ||
}, | ||
} | ||
nginxPlus := true | ||
hasAppProtect := true | ||
for _, test := range tests { | ||
cm := &v1.ConfigMap{ | ||
Data: map[string]string{ | ||
"app-protect-compressed-requests-action": test.action, | ||
}, | ||
} | ||
result := ParseConfigMap(cm, nginxPlus, hasAppProtect) | ||
if result.MainAppProtectCompressedRequestsAction != test.expect { | ||
t.Errorf("ParseConfigMap() returned %q but expected %q for the case %s", result.MainAppProtectCompressedRequestsAction, test.expect, test.msg) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters