mirror of
https://github.com/kiwix/libkiwix.git
synced 2025-06-26 10:11:30 +00:00
User language control via userlang cookie
This commit is contained in:
committed by
Matthieu Gautier
parent
600ff07986
commit
14f0f79061
@ -1042,6 +1042,46 @@ TEST_F(ServerTest, UserLanguageControl)
|
||||
/*Response Set-Cookie:*/ "userlang=test",
|
||||
/* expected <h1> */ "[I18N TESTING] Content not found, but at least the server is alive"
|
||||
},
|
||||
{
|
||||
"userlang cookie is respected",
|
||||
/*url*/ "/ROOT/content/zimfile/invalid-article",
|
||||
/*Accept-Language:*/ "",
|
||||
/*Request Cookie:*/ "userlang=test",
|
||||
/*Response Set-Cookie:*/ "userlang=test",
|
||||
/* expected <h1> */ "[I18N TESTING] Content not found, but at least the server is alive"
|
||||
},
|
||||
{
|
||||
"userlang cookie is correctly parsed",
|
||||
/*url*/ "/ROOT/content/zimfile/invalid-article",
|
||||
/*Accept-Language:*/ "",
|
||||
/*Request Cookie:*/ "anothercookie=123; userlang=test",
|
||||
/*Response Set-Cookie:*/ "userlang=test",
|
||||
/* expected <h1> */ "[I18N TESTING] Content not found, but at least the server is alive"
|
||||
},
|
||||
{
|
||||
"userlang cookie is correctly parsed",
|
||||
/*url*/ "/ROOT/content/zimfile/invalid-article",
|
||||
/*Accept-Language:*/ "",
|
||||
/*Request Cookie:*/ "userlang=test; anothercookie=abc",
|
||||
/*Response Set-Cookie:*/ "userlang=test",
|
||||
/* expected <h1> */ "[I18N TESTING] Content not found, but at least the server is alive"
|
||||
},
|
||||
{
|
||||
"userlang cookie is correctly parsed",
|
||||
/*url*/ "/ROOT/content/zimfile/invalid-article",
|
||||
/*Accept-Language:*/ "",
|
||||
/*Request Cookie:*/ "cookie1=abc; userlang=test; cookie2=xyz",
|
||||
/*Response Set-Cookie:*/ "userlang=test",
|
||||
/* expected <h1> */ "[I18N TESTING] Content not found, but at least the server is alive"
|
||||
},
|
||||
{
|
||||
"Multiple userlang cookies are not a problem",
|
||||
/*url*/ "/ROOT/content/zimfile/invalid-article",
|
||||
/*Accept-Language:*/ "",
|
||||
/*Request Cookie:*/ "cookie1=abc; userlang=en; userlang=test; cookie2=xyz",
|
||||
/*Response Set-Cookie:*/ "userlang=test",
|
||||
/* expected <h1> */ "[I18N TESTING] Content not found, but at least the server is alive"
|
||||
},
|
||||
{
|
||||
"userlang query parameter takes precedence over Accept-Language",
|
||||
/*url*/ "/ROOT/content/zimfile/invalid-article?userlang=en",
|
||||
@ -1050,6 +1090,22 @@ TEST_F(ServerTest, UserLanguageControl)
|
||||
/*Response Set-Cookie:*/ "userlang=en",
|
||||
/* expected <h1> */ "Not Found"
|
||||
},
|
||||
{
|
||||
"userlang query parameter takes precedence over its cookie counterpart",
|
||||
/*url*/ "/ROOT/content/zimfile/invalid-article?userlang=en",
|
||||
/*Accept-Language:*/ "",
|
||||
/*Request Cookie:*/ "userlang=test",
|
||||
/*Response Set-Cookie:*/ "userlang=en",
|
||||
/* expected <h1> */ "Not Found"
|
||||
},
|
||||
{
|
||||
"userlang in cookies takes precedence over Accept-Language",
|
||||
/*url*/ "/ROOT/content/zimfile/invalid-article",
|
||||
/*Accept-Language:*/ "test",
|
||||
/*Request Cookie:*/ "userlang=en",
|
||||
/*Response Set-Cookie:*/ "userlang=en",
|
||||
/* expected <h1> */ "Not Found"
|
||||
},
|
||||
{
|
||||
"The value of the Accept-Language header is not currently parsed.",
|
||||
// In case of a comma separated list of languages (optionally weighted
|
||||
|
Reference in New Issue
Block a user