GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — cloudstorage/store_test.go at master · lytics/cloudstorage Expand file tree/ Copy pathstore_test.goMore file actions 91 lines (79 loc) · 2.41 KB / Copy pathstore_test.goFile metadata and controls91 lines (79 loc) · 2.41 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 package cloudstorage_test import ( "encoding/json" "path/filepath" "testing" "github.com/lytics/cloudstorage" "github.com/lytics/cloudstorage/localfs" "github.com/stretchr/testify/require" ) func TestStore(t *testing.T) { tmpDir := t.TempDir() invalidConf := &cloudstorage.Config{} store, err := cloudstorage.NewStore(invalidConf) require.Error(t, err) require.Nil(t, store) missingStoreConf := &cloudstorage.Config{ Type: "non-existent-store", } store, err = cloudstorage.NewStore(missingStoreConf) require.Error(t, err) require.Nil(t, store) // test missing temp dir, assign local temp localFsConf := &cloudstorage.Config{ Type: localfs.StoreType, AuthMethod: localfs.AuthFileSystem, LocalFS: filepath.Join(tmpDir, "mockcloud"), } store, err = cloudstorage.NewStore(localFsConf) require.Nil(t, err) require.NotNil(t, store) } func TestJwtConf(t *testing.T) { configInput := ` { "JwtConf": { "type": "service_account", "project_id": "testing", "private_key_id": "abcdefg", "private_key": "aGVsbG8td29ybGQ=", "client_email": "[email protected]", "client_id": "117058426251532209964", "scopes": [ "https://www.googleapis.com/auth/devstorage.read_write" ] } }` // v := base64.StdEncoding.EncodeToString([]byte("hello-world")) // t.Logf("b64 %q", v) conf := &cloudstorage.Config{} err := json.Unmarshal([]byte(configInput), conf) require.Nil(t, err) conf.JwtConf.PrivateKey = "------helo-------\naGVsbG8td29ybGQ=\n-----------------end--------" require.NotNil(t, conf.JwtConf) require.Nil(t, conf.JwtConf.Validate()) require.Equal(t, "aGVsbG8td29ybGQ=", conf.JwtConf.PrivateKey) require.Equal(t, "service_account", conf.JwtConf.Type) // note on this one the "keytype" & "private_keybase64" configInput = ` { "JwtConf": { "keytype": "service_account", "project_id": "testing", "private_key_id": "abcdefg", "private_keybase64": "aGVsbG8td29ybGQ=", "client_email": "[email protected]", "client_id": "117058426251532209964", "scopes": [ "https://www.googleapis.com/auth/devstorage.read_write" ] } }` conf = &cloudstorage.Config{} err = json.Unmarshal([]byte(configInput), conf) require.Nil(t, err) require.NotNil(t, conf.JwtConf) require.Nil(t, conf.JwtConf.Validate()) require.Equal(t, "aGVsbG8td29ybGQ=", conf.JwtConf.PrivateKey) require.Equal(t, "service_account", conf.JwtConf.Type) } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |