1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-06 17:40:58 +00:00

Make all secrets case insensitive by formatting them to uppercase (#470)

* Uppercase secrets, print error when secret with same name already exists

* Test lower-to-upper case formatting for secrets
This commit is contained in:
Cat™ 2021-01-12 17:54:53 +00:00 committed by GitHub
parent 501e2e4d5f
commit 078494e07c
3 changed files with 15 additions and 0 deletions

View file

@ -14,6 +14,9 @@ func TestEvaluate(t *testing.T) {
rc := &RunContext{
Config: &Config{
Workdir: ".",
Secrets: map[string]string{
"LOWER_CASE_SECRET": "value",
},
},
Env: map[string]string{
"key": "value",
@ -102,6 +105,7 @@ func TestEvaluate(t *testing.T) {
{"matrix.os", "Linux", ""},
{"matrix.foo", "bar", ""},
{"env.key", "value", ""},
{"secrets.lower_case_secret", "value", ""},
}
for _, table := range tables {
@ -124,6 +128,9 @@ func TestInterpolate(t *testing.T) {
rc := &RunContext{
Config: &Config{
Workdir: ".",
Secrets: map[string]string{
"LOWER_CASE_SECRET": "value",
},
},
Env: map[string]string{
"KEYWITHNOTHING": "valuewithnothing",
@ -151,6 +158,7 @@ func TestInterpolate(t *testing.T) {
{" ${{ env.KEYWITHNOTHING }} ", " valuewithnothing "},
{" ${{ env.KEY-WITH-HYPHENS }} ", " value-with-hyphens "},
{" ${{ env.KEY_WITH_UNDERSCORES }} ", " value_with_underscores "},
{" ${{ secrets.lower_case_secret }} ", " value "},
{"${{ env.UNKNOWN }}", ""},
{"${{ env.SOMETHING_TRUE }}", "true"},
{"${{ env.SOMETHING_FALSE }}", "false"},