Always include user and device ID in API request headers, so that they're available in all server-side handlers

This commit is contained in:
David Dworken
2023-10-14 10:52:35 -07:00
parent 54c3429bca
commit fca2b1441f
12 changed files with 87 additions and 62 deletions

View File

@ -362,13 +362,14 @@ func TestAugmentedIsOfflineError(t *testing.T) {
defer testutils.BackupAndRestore(t)()
defer testutils.RunTestServer()()
defer testutils.BackupAndRestoreEnv("HISHTORY_SIMULATE_NETWORK_ERROR")()
ctx := hctx.MakeContext()
// By default, when the hishtory server is up, then IsOfflineError checks the error msg
require.True(t, isHishtoryServerUp())
require.False(t, IsOfflineError(fmt.Errorf("unchecked error type")))
require.True(t, isHishtoryServerUp(ctx))
require.False(t, IsOfflineError(ctx, fmt.Errorf("unchecked error type")))
// When the hishtory server is down, then all error messages are treated as being due to offline errors
os.Setenv("HISHTORY_SIMULATE_NETWORK_ERROR", "1")
require.False(t, isHishtoryServerUp())
require.True(t, IsOfflineError(fmt.Errorf("unchecked error type")))
require.False(t, isHishtoryServerUp(ctx))
require.True(t, IsOfflineError(ctx, fmt.Errorf("unchecked error type")))
}