Skip to content

Commit 4c5ed20

Browse files
CopilotAniruddh25
andcommitted
Remove added test data to avoid breaking existing tests - use existing book with % character instead
Co-authored-by: Aniruddh25 <[email protected]>
1 parent a78b348 commit 4c5ed20

9 files changed

Lines changed: 15 additions & 185 deletions

src/Service.Tests/DatabaseSchema-DwSql.sql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,7 @@ VALUES (1, 'Awesome book', 1234),
337337
(18, '[Special Book]', 1234),
338338
(19, 'ME\YOU', 1234),
339339
(20, 'C:\\LIFE', 1234),
340-
(21, '', 1234),
341-
(22, 'filter & test', 1234),
342-
(23, 'A+B=C', 1234),
343-
(24, 'Tom & Jerry', 1234),
344-
(25, '100% Complete', 1234);
340+
(21, '', 1234);
345341

346342
INSERT INTO book_website_placements(id, book_id, price) VALUES (1, 1, 100), (2, 2, 50), (3, 3, 23), (4, 5, 33);
347343

src/Service.Tests/DatabaseSchema-MsSql.sql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,7 @@ VALUES (1, 'Awesome book', 1234),
532532
(18, '[Special Book]', 1234),
533533
(19, 'ME\YOU', 1234),
534534
(20, 'C:\\LIFE', 1234),
535-
(21, '', 1234),
536-
(22, 'filter & test', 1234),
537-
(23, 'A+B=C', 1234),
538-
(24, 'Tom & Jerry', 1234),
539-
(25, '100% Complete', 1234);
535+
(21, '', 1234);
540536
SET IDENTITY_INSERT books OFF
541537

542538
SET IDENTITY_INSERT books_mm ON

src/Service.Tests/DatabaseSchema-MySql.sql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,7 @@ INSERT INTO books(id, title, publisher_id)
389389
(18, '[Special Book]', 1234),
390390
(19, 'ME\\YOU', 1234),
391391
(20, 'C:\\\\LIFE', 1234),
392-
(21, '', 1234),
393-
(22, 'filter & test', 1234),
394-
(23, 'A+B=C', 1234),
395-
(24, 'Tom & Jerry', 1234),
396-
(25, '100% Complete', 1234);
392+
(21, '', 1234);
397393
INSERT INTO book_website_placements(book_id, price) VALUES (1, 100), (2, 50), (3, 23), (5, 33);
398394
INSERT INTO website_users(id, username) VALUES (1, 'George'), (2, NULL), (3, ''), (4, 'book_lover_95'), (5, 'null');
399395
INSERT INTO book_author_link(book_id, author_id) VALUES (1, 123), (2, 124), (3, 123), (3, 124), (4, 123), (4, 124), (5, 126);

src/Service.Tests/DatabaseSchema-PostgreSql.sql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,7 @@ INSERT INTO books(id, title, publisher_id)
392392
(18, '[Special Book]', 1234),
393393
(19, 'ME\YOU', 1234),
394394
(20, 'C:\\LIFE', 1234),
395-
(21, '', 1234),
396-
(22, 'filter & test', 1234),
397-
(23, 'A+B=C', 1234),
398-
(24, 'Tom & Jerry', 1234),
399-
(25, '100% Complete', 1234);
395+
(21, '', 1234);
400396
INSERT INTO book_website_placements(book_id, price) VALUES (1, 100), (2, 50), (3, 23), (5, 33);
401397
INSERT INTO website_users(id, username) VALUES (1, 'George'), (2, NULL), (3, ''), (4, 'book_lover_95'), (5, 'null');
402398
INSERT INTO book_author_link(book_id, author_id) VALUES (1, 123), (2, 124), (3, 123), (3, 124), (4, 123), (4, 124), (5, 126);;

src/Service.Tests/SqlTests/RestApiTests/Find/DwSqlFindApiTests.cs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -224,25 +224,7 @@ public class DwSqlFindApiTests : FindApiTestBase
224224
{
225225
"FindTestWithFilterContainingSpecialCharacters",
226226
$"SELECT * FROM { _integrationTableName } " +
227-
$"WHERE title = 'filter & test' " +
228-
$"FOR JSON PATH, INCLUDE_NULL_VALUES"
229-
},
230-
{
231-
"FindTestWithFilterContainingMultipleSpecialCharacters",
232-
$"SELECT * FROM { _integrationTableName } " +
233-
$"WHERE title = 'A+B=C' " +
234-
$"FOR JSON PATH, INCLUDE_NULL_VALUES"
235-
},
236-
{
237-
"FindTestWithFilterContainingAmpersandInPhrase",
238-
$"SELECT * FROM { _integrationTableName } " +
239-
$"WHERE title = 'Tom & Jerry' " +
240-
$"FOR JSON PATH, INCLUDE_NULL_VALUES"
241-
},
242-
{
243-
"FindTestWithFilterContainingPercentSign",
244-
$"SELECT * FROM { _integrationTableName } " +
245-
$"WHERE title = '100% Complete' " +
227+
$"WHERE title = 'SOME%CONN' " +
246228
$"FOR JSON PATH, INCLUDE_NULL_VALUES"
247229
},
248230
{

src/Service.Tests/SqlTests/RestApiTests/Find/FindApiTestBase.cs

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -695,79 +695,30 @@ await SetupAndRunRestApiTest(
695695

696696
/// <summary>
697697
/// Tests the REST Api for Find operation with a filter containing special characters
698-
/// like ampersand (&) that need to be URL-encoded. This validates that the fix for
699-
/// the double-decoding issue is working correctly.
698+
/// that need to be URL-encoded. Uses existing book with '%' character (SOME%CONN).
699+
/// This validates that the fix for the double-decoding issue is working correctly.
700700
/// </summary>
701701
[TestMethod]
702702
public async Task FindTestWithFilterContainingSpecialCharacters()
703703
{
704+
// Testing with SOME%CONN - the %25 is URL-encoded %
704705
await SetupAndRunRestApiTest(
705706
primaryKeyRoute: string.Empty,
706-
queryString: "?$filter=title%20eq%20%27filter%20%26%20test%27",
707+
queryString: "?$filter=title%20eq%20%27SOME%25CONN%27",
707708
entityNameOrPath: _integrationEntityName,
708709
sqlQuery: GetQuery(nameof(FindTestWithFilterContainingSpecialCharacters))
709710
);
710711
}
711712

712713
/// <summary>
713-
/// Tests the REST Api for Find operation with filters containing various special characters
714-
/// that need URL encoding: plus (+), equals (=), and percent (%).
715-
/// Validates that multiple types of special characters are handled correctly.
716-
/// </summary>
717-
[TestMethod]
718-
public async Task FindTestWithFilterContainingMultipleSpecialCharacters()
719-
{
720-
// Test with plus and equals signs - URL-encoded
721-
await SetupAndRunRestApiTest(
722-
primaryKeyRoute: string.Empty,
723-
queryString: "?$filter=title%20eq%20%27A%2BB%3DC%27",
724-
entityNameOrPath: _integrationEntityName,
725-
sqlQuery: GetQuery(nameof(FindTestWithFilterContainingMultipleSpecialCharacters))
726-
);
727-
}
728-
729-
/// <summary>
730-
/// Tests the REST Api for Find operation with a filter containing ampersand
731-
/// in a different context to ensure robustness across various data patterns.
732-
/// </summary>
733-
[TestMethod]
734-
public async Task FindTestWithFilterContainingAmpersandInPhrase()
735-
{
736-
await SetupAndRunRestApiTest(
737-
primaryKeyRoute: string.Empty,
738-
queryString: "?$filter=title%20eq%20%27Tom%20%26%20Jerry%27",
739-
entityNameOrPath: _integrationEntityName,
740-
sqlQuery: GetQuery(nameof(FindTestWithFilterContainingAmpersandInPhrase))
741-
);
742-
}
743-
744-
/// <summary>
745-
/// Tests the REST Api for Find operation with a filter containing percent sign (%)
746-
/// which has special meaning in URL encoding and SQL LIKE patterns.
747-
/// </summary>
748-
[TestMethod]
749-
public async Task FindTestWithFilterContainingPercentSign()
750-
{
751-
await SetupAndRunRestApiTest(
752-
primaryKeyRoute: string.Empty,
753-
queryString: "?$filter=title%20eq%20%27100%25%20Complete%27",
754-
entityNameOrPath: _integrationEntityName,
755-
sqlQuery: GetQuery(nameof(FindTestWithFilterContainingPercentSign))
756-
);
757-
}
758-
759-
/// <summary>
760-
/// Tests the REST Api for Find operation with an $orderby clause containing special characters.
761-
/// When column names or values in orderby contain special characters like spaces that need
762-
/// URL encoding, this validates the fix preserves the encoding correctly.
763-
/// Note: While this test uses 'title' (which has special chars in values not the column name),
764-
/// it validates that $orderby parameter extraction preserves URL encoding through the same
714+
/// Tests the REST Api for Find operation with an $orderby clause containing URL-encoded spaces.
715+
/// This validates that $orderby parameter extraction preserves URL encoding through the same
765716
/// code path as $filter.
766717
/// </summary>
767718
[TestMethod]
768719
public async Task FindTestWithOrderByContainingSpecialCharacters()
769720
{
770-
// Order by title - tests that $orderby parameter is extracted with URL encoding preserved
721+
// Order by title desc - tests that $orderby parameter is extracted with URL encoding preserved
771722
// The %20 represents space in "$orderby=title%20desc"
772723
await SetupAndRunRestApiTest(
773724
primaryKeyRoute: string.Empty,

src/Service.Tests/SqlTests/RestApiTests/Find/MsSqlFindApiTests.cs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -231,25 +231,7 @@ public class MsSqlFindApiTests : FindApiTestBase
231231
{
232232
"FindTestWithFilterContainingSpecialCharacters",
233233
$"SELECT * FROM { _integrationTableName } " +
234-
$"WHERE title = 'filter & test' " +
235-
$"FOR JSON PATH, INCLUDE_NULL_VALUES"
236-
},
237-
{
238-
"FindTestWithFilterContainingMultipleSpecialCharacters",
239-
$"SELECT * FROM { _integrationTableName } " +
240-
$"WHERE title = 'A+B=C' " +
241-
$"FOR JSON PATH, INCLUDE_NULL_VALUES"
242-
},
243-
{
244-
"FindTestWithFilterContainingAmpersandInPhrase",
245-
$"SELECT * FROM { _integrationTableName } " +
246-
$"WHERE title = 'Tom & Jerry' " +
247-
$"FOR JSON PATH, INCLUDE_NULL_VALUES"
248-
},
249-
{
250-
"FindTestWithFilterContainingPercentSign",
251-
$"SELECT * FROM { _integrationTableName } " +
252-
$"WHERE title = '100% Complete' " +
234+
$"WHERE title = 'SOME%CONN' " +
253235
$"FOR JSON PATH, INCLUDE_NULL_VALUES"
254236
},
255237
{

src/Service.Tests/SqlTests/RestApiTests/Find/MySqlFindApiTests.cs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -404,43 +404,7 @@ SELECT JSON_ARRAYAGG(JSON_OBJECT('id', id, 'title', title, 'publisher_id', publi
404404
FROM (
405405
SELECT *
406406
FROM " + _integrationTableName + @"
407-
WHERE title = 'filter & test'
408-
ORDER BY id asc
409-
) AS subq
410-
"
411-
},
412-
{
413-
"FindTestWithFilterContainingMultipleSpecialCharacters",
414-
@"
415-
SELECT JSON_ARRAYAGG(JSON_OBJECT('id', id, 'title', title, 'publisher_id', publisher_id)) AS data
416-
FROM (
417-
SELECT *
418-
FROM " + _integrationTableName + @"
419-
WHERE title = 'A+B=C'
420-
ORDER BY id asc
421-
) AS subq
422-
"
423-
},
424-
{
425-
"FindTestWithFilterContainingAmpersandInPhrase",
426-
@"
427-
SELECT JSON_ARRAYAGG(JSON_OBJECT('id', id, 'title', title, 'publisher_id', publisher_id)) AS data
428-
FROM (
429-
SELECT *
430-
FROM " + _integrationTableName + @"
431-
WHERE title = 'Tom & Jerry'
432-
ORDER BY id asc
433-
) AS subq
434-
"
435-
},
436-
{
437-
"FindTestWithFilterContainingPercentSign",
438-
@"
439-
SELECT JSON_ARRAYAGG(JSON_OBJECT('id', id, 'title', title, 'publisher_id', publisher_id)) AS data
440-
FROM (
441-
SELECT *
442-
FROM " + _integrationTableName + @"
443-
WHERE title = '100% Complete'
407+
WHERE title = 'SOME%CONN'
444408
ORDER BY id asc
445409
) AS subq
446410
"

src/Service.Tests/SqlTests/RestApiTests/Find/PostgreSqlFindApiTests.cs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -418,40 +418,7 @@ SELECT json_agg(to_jsonb(subq)) AS data
418418
FROM (
419419
SELECT *
420420
FROM " + _integrationTableName + @"
421-
WHERE title = 'filter & test'
422-
ORDER BY id asc
423-
) AS subq"
424-
},
425-
{
426-
"FindTestWithFilterContainingMultipleSpecialCharacters",
427-
@"
428-
SELECT json_agg(to_jsonb(subq)) AS data
429-
FROM (
430-
SELECT *
431-
FROM " + _integrationTableName + @"
432-
WHERE title = 'A+B=C'
433-
ORDER BY id asc
434-
) AS subq"
435-
},
436-
{
437-
"FindTestWithFilterContainingAmpersandInPhrase",
438-
@"
439-
SELECT json_agg(to_jsonb(subq)) AS data
440-
FROM (
441-
SELECT *
442-
FROM " + _integrationTableName + @"
443-
WHERE title = 'Tom & Jerry'
444-
ORDER BY id asc
445-
) AS subq"
446-
},
447-
{
448-
"FindTestWithFilterContainingPercentSign",
449-
@"
450-
SELECT json_agg(to_jsonb(subq)) AS data
451-
FROM (
452-
SELECT *
453-
FROM " + _integrationTableName + @"
454-
WHERE title = '100% Complete'
421+
WHERE title = 'SOME%CONN'
455422
ORDER BY id asc
456423
) AS subq"
457424
},

0 commit comments

Comments
 (0)