fix auth with long username or password

Our auth_headers() helper uses base64.encodestring() which inserts
newlines to generate a nicely formatted text. That is surely helpful for
display purposes but unwanted when forging an authentication string.

encodestring() always append a newline, which was the reason for the
[:-1] slicing.

Switch to base64.b64encoding() and add a test ensuring no newline is
inserted.

Closes-Bug: 1039307
Change-Id: I71c3e6d504a500a1f21ff89b1d54a155da1aaf0e
Merge "fix auth with long username or password"