ws: Add a timeout during test-webservice.c tests using alarm()

We may want to expand this further once we get some experience with
how it works.

Closes #577
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Don't send "ping" commands during test-webservice.c tests

This would previously limit the tests to having to run in
5 seconds or less, or erroneous results would result.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Separate function for parsing auth input in CockpitAuth

This allows us to test the real parsing functionality in our
test-auth tests.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Check that JSON is UTF8 before parsing it

Recent versions of json-glib do this (0.99.2 and later) but we need this
guarantee on earlier versions as well. Do the check on our own in
those cases. And define the JSON_PARSER_ERROR_INVALID_DATA error code
when it is not around.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Handle cases where login is not UTF8 valid

Produce an intelligent error message in these cases. cockpit-session
would have produced invalid JSON output here, and so we catch and
handle in properly.

Fixes #507
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Remove some useless rhost stuff in CockpitWebService
ws: Only share sessions if channel uses normal user/key

If a channel requests a specific user or host key, then force a
new session/agent for that channel.
ws: Test that a session without channel times out

This only happens after all channels have been closed. Refactor
things a bit to make testing easier.
ws: No need for tracking the connection in CockpitWebService

Not used for anything any longer. Removing this also fixes
a leak.
agent: Make the authorize cookie a string

This lets us use the polkit agent cookie directly, and also lets
us have a simple implementation in CockpitWebService

Fixes a crasher in the previous commit.
ws: Handle multiple WebSockets per CockpitWebService

Multiple web sockets can be served from a single CockpitWebService,
which allows tabs to share sessions, as well as coherent implementations
of /logout and resource handlers.
ws: CockpitAuth owns CockpitWebService instances

Each time a real login occurs, we instantiate a new CockpitWebService
and return that same instance when logging in with cookies.

When doing /logout we dispose that web service instance, and force
it to disconnect.

Fixes #495
Closes #565