| index 5734179d2..fcb679efe 100644 |
| --- a/internal/schedule/declaration_test.go |
| +++ b/internal/schedule/declaration_test.go |
| @@ -97,6 +97,44 @@ func TestReadDeclarationAbsentIsEmpty(t *testing.T) { |
| } |
| } |
| |
| +// ReadDeclaration takes an acct/app straight off a URL path in the console |
| +// door; it must refuse a malformed one itself rather than build a bucket |
| +// key from it and let the store report a confusing not-found. |
| +func TestReadDeclarationRejectsBadIDs(t *testing.T) { |
| + ctx := context.Background() |
| + st := release.NewDirStore(t.TempDir()) |
| + for _, tc := range []struct{ acct, app string }{ |
| + {"", "app"}, |
| + {"bab", ""}, |
| + {"BAB", "app"}, |
| + {"bab", "App"}, |
| + {"bab/../x", "app"}, |
| + } { |
| + if _, _, err := ReadDeclaration(ctx, st, tc.acct, tc.app); err == nil { |
| + t.Errorf("ReadDeclaration(%q, %q) = nil error, want a refusal", tc.acct, tc.app) |
| + } |
| + } |
| +} |
| + |
| +func TestCheckIDs(t *testing.T) { |
| + if err := checkIDs("bab", "app"); err != nil { |
| + t.Fatalf("checkIDs(valid) = %v", err) |
| + } |
| + for _, tc := range []struct{ acct, app string }{ |
| + {"", "app"}, |
| + {"bab", ""}, |
| + {"BAB", "app"}, |
| + {"bab", "App"}, |
| + {"b", "app"}, // too short for acctRe |
| + {"bab", "-app"}, // appRe wants a leading letter |
| + {"bab", "app/../etc"}, |
| + } { |
| + if err := checkIDs(tc.acct, tc.app); err == nil { |
| + t.Errorf("checkIDs(%q, %q) = nil, want a refusal", tc.acct, tc.app) |
| + } |
| + } |
| +} |
| + |
| func TestTouchRunMovesTheEtag(t *testing.T) { |
| ctx := context.Background() |
| st := release.NewDirStore(t.TempDir()) |