(t *testing.T)
| 2837 | } |
| 2838 | |
| 2839 | func TestDbConfigCredentials(t *testing.T) { |
| 2840 | if base.UnitTestUrlIsWalrus() { |
| 2841 | t.Skip("This test only works against Couchbase Server") |
| 2842 | } |
| 2843 | |
| 2844 | rt := rest.NewRestTesterPersistentConfig(t) |
| 2845 | defer rt.Close() |
| 2846 | |
| 2847 | var dbConfig rest.DatabaseConfig |
| 2848 | resp := rt.SendAdminRequest(http.MethodGet, "/db/_config", "") |
| 2849 | rest.RequireStatus(t, resp, http.StatusOK) |
| 2850 | require.NoError(t, base.JSONUnmarshal(resp.Body.Bytes(), &dbConfig)) |
| 2851 | |
| 2852 | // non-runtime config, we don't expect to see any credentials present |
| 2853 | assert.Equal(t, "", dbConfig.Username) |
| 2854 | assert.Equal(t, "", dbConfig.Password) |
| 2855 | assert.Equal(t, "", dbConfig.CACertPath) |
| 2856 | assert.Equal(t, "", dbConfig.CertPath) |
| 2857 | assert.Equal(t, "", dbConfig.KeyPath) |
| 2858 | |
| 2859 | resp = rt.SendAdminRequest(http.MethodGet, "/db/_config?include_runtime=true", "") |
| 2860 | rest.RequireStatus(t, resp, http.StatusOK) |
| 2861 | require.NoError(t, base.JSONUnmarshal(resp.Body.Bytes(), &dbConfig)) |
| 2862 | |
| 2863 | // runtime config, we expect to see the credentials used by the database (either bootstrap or per-db - but in this case, bootstrap) |
| 2864 | assert.Equal(t, base.TestClusterUsername(), dbConfig.Username) |
| 2865 | assert.Equal(t, base.RedactedStr, dbConfig.Password) |
| 2866 | assert.Equal(t, "", dbConfig.CACertPath) |
| 2867 | assert.Equal(t, "", dbConfig.CertPath) |
| 2868 | assert.Equal(t, "", dbConfig.KeyPath) |
| 2869 | } |
| 2870 | |
| 2871 | func TestInvalidDBConfig(t *testing.T) { |
| 2872 | rt := rest.NewRestTesterPersistentConfig(t) |
nothing calls this directly
no test coverage detected