mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 10:37:56 +00:00 
			
		
		
		
	Allow reading of config in sql backends
This commit is contained in:
		| @@ -5,6 +5,7 @@ import ( | ||||
| 	"fmt" | ||||
| 	"log" | ||||
| 	"os" | ||||
| 	"reflect" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/hashicorp/vault/logical" | ||||
| @@ -13,6 +14,48 @@ import ( | ||||
| 	"github.com/mitchellh/mapstructure" | ||||
| ) | ||||
|  | ||||
| func TestBackend_config_connection(t *testing.T) { | ||||
| 	var resp *logical.Response | ||||
| 	var err error | ||||
| 	config := logical.TestBackendConfig() | ||||
| 	config.StorageView = &logical.InmemStorage{} | ||||
| 	b, err := Factory(config) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
|  | ||||
| 	configData := map[string]interface{}{ | ||||
| 		"connection_url":       "sample_connection_url", | ||||
| 		"max_open_connections": 9, | ||||
| 		"max_idle_connections": 7, | ||||
| 		"verify_connection":    false, | ||||
| 	} | ||||
|  | ||||
| 	configReq := &logical.Request{ | ||||
| 		Operation: logical.UpdateOperation, | ||||
| 		Path:      "config/connection", | ||||
| 		Storage:   config.StorageView, | ||||
| 		Data:      configData, | ||||
| 	} | ||||
| 	resp, err = b.HandleRequest(configReq) | ||||
| 	if err != nil || (resp != nil && resp.IsError()) { | ||||
| 		t.Fatalf("err:%s resp:%#v\n", err, resp) | ||||
| 	} | ||||
| 	if resp != nil { | ||||
| 		t.Fatalf("expected a nil response") | ||||
| 	} | ||||
|  | ||||
| 	configReq.Operation = logical.ReadOperation | ||||
| 	resp, err = b.HandleRequest(configReq) | ||||
| 	if err != nil || (resp != nil && resp.IsError()) { | ||||
| 		t.Fatalf("err:%s resp:%#v\n", err, resp) | ||||
| 	} | ||||
|  | ||||
| 	if !reflect.DeepEqual(configData, resp.Data) { | ||||
| 		t.Fatalf("bad: expected:%#v\nactual:%#v\n", configData, resp.Data) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestBackend_basic(t *testing.T) { | ||||
| 	b, _ := Factory(logical.TestBackendConfig()) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 vishalnayak
					vishalnayak