UnifiedPush: Treat non-Basic/Bearer Authorization header like header was not sent

This commit is contained in:
binwiederhier 2023-02-23 10:15:57 -05:00
parent 2ac63c4327
commit 422ad0cc5d
3 changed files with 32 additions and 3 deletions

View file

@ -796,6 +796,25 @@ func TestServer_Auth_ViaQuery(t *testing.T) {
require.Equal(t, 401, response.Code)
}
func TestServer_Auth_NonBasicHeader(t *testing.T) {
s := newTestServer(t, newTestConfigWithAuthFile(t))
response := request(t, s, "PUT", "/mytopic", "test", map[string]string{
"Authorization": "WebPush not-supported",
})
require.Equal(t, 200, response.Code)
response = request(t, s, "PUT", "/mytopic", "test", map[string]string{
"Authorization": "Bearer supported",
})
require.Equal(t, 401, response.Code)
response = request(t, s, "PUT", "/mytopic", "test", map[string]string{
"Authorization": "basic supported",
})
require.Equal(t, 401, response.Code)
}
func TestServer_StatsResetter(t *testing.T) {
// This tests the stats resetter for
// - an anonymous user