Skip to content

Commit 36843c0

Browse files
committed
Cover the permissive path at the DAO layer
Signed-off-by: Prasanth Baskar <prasanth@8gears.com>
1 parent f9e397f commit 36843c0

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/lib/orm/filter_value_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ func TestValidateFilterValue(t *testing.T) {
7979
{"text column takes a range of any literal", stringField, q.NewRange("a", "b"), false},
8080
{"unknown field type", nil, "abc", false},
8181
{"nil value", intField, nil, false},
82+
{"time exact match with an RFC3339 string", timeField, "2020-01-02T03:04:05Z", false},
83+
{"bytes operand against a text column", stringField, []byte("abc"), false},
8284
}
8385

8486
for _, tc := range cases {

src/pkg/project/dao/dao_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,24 @@ func (suite *DaoTestSuite) TestListRoles() {
434434

435435
// A query operand the column cannot take must be reported as a bad request
436436
// rather than letting the Postgres syntax error surface as a 500.
437+
// Valid operands must keep filtering after the validation was added.
438+
func (suite *DaoTestSuite) TestListValidFilterValue() {
439+
for _, query := range []string{
440+
"creation_time=[2020-01-01~2021-01-01]",
441+
"creation_time=[2020-01-01T00:00:00~2021-01-01T00:00:00]",
442+
"project_id=1",
443+
"name=library",
444+
} {
445+
suite.Run(query, func() {
446+
built, err := q.Build(query, "", 1, 10)
447+
suite.Require().Nil(err)
448+
449+
_, err = suite.dao.List(orm.Context(), built)
450+
suite.Nil(err)
451+
})
452+
}
453+
}
454+
437455
func (suite *DaoTestSuite) TestListInvalidFilterValue() {
438456
for _, query := range []string{
439457
"creation_time=[a~b]",

0 commit comments

Comments
 (0)