(#16753) Improve test to check contents of written file
The previous test didn't check that the file was written with the right
contents. This checks at least a portion of the contents. This also
simplifies the test a bit to use a temp directory for holding the auth
file that is used to allow the agent access to the master.