fix(tests): URL-encode series name in special characters test
The TestGetSeries_SpecialCharactersInName test was failing with a 400 status because the series name 'Series: Book & Other (Vol. 1)' was interpolated directly into the URL without encoding. The ampersand was parsed as a query parameter delimiter, corrupting the request. Use url.QueryEscape() to properly encode the name parameter.
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@@ -254,7 +255,7 @@ func (s *SeriesIntegrationTestSuite) TestGetSeriesBooks_Unauthorized() {
|
|||||||
|
|
||||||
func (s *SeriesIntegrationTestSuite) TestGetSeries_SpecialCharactersInName() {
|
func (s *SeriesIntegrationTestSuite) TestGetSeries_SpecialCharactersInName() {
|
||||||
seriesName := "Series: Book & Other (Vol. 1)"
|
seriesName := "Series: Book & Other (Vol. 1)"
|
||||||
url := fmt.Sprintf("%s/api/series/books?library_id=%s&name=%s", s.setup.Server.URL, s.libraryID, seriesName)
|
url := fmt.Sprintf("%s/api/series/books?library_id=%s&name=%s", s.setup.Server.URL, s.libraryID, url.QueryEscape(seriesName))
|
||||||
req, _ := http.NewRequest("GET", url, nil)
|
req, _ := http.NewRequest("GET", url, nil)
|
||||||
req.Header.Set("Authorization", "Bearer "+s.token)
|
req.Header.Set("Authorization", "Bearer "+s.token)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user