()
| 35 | const defaultToken = "notasecret" |
| 36 | |
| 37 | func (s *testSuite) TestNewManager() { |
| 38 | assert := assert.New(s.T()) |
| 39 | |
| 40 | testCases := []struct { |
| 41 | name string |
| 42 | connection string |
| 43 | token string |
| 44 | path string |
| 45 | prefix string |
| 46 | expectedError bool |
| 47 | role credentials.Role |
| 48 | }{ |
| 49 | {name: "missing token", connection: s.connectionString, expectedError: true}, |
| 50 | {name: "missing address", token: defaultToken, expectedError: true}, |
| 51 | {name: "invalid address reader", token: defaultToken, connection: "http://non-existing:5000", expectedError: true, role: credentials.RoleReader}, |
| 52 | {name: "invalid address writer", token: defaultToken, connection: "http://non-existing:5000", expectedError: true}, |
| 53 | {name: "invalid mount path", token: defaultToken, connection: s.connectionString, path: "non-existing", expectedError: true}, |
| 54 | {name: "valid connection reader", connection: s.connectionString, token: defaultToken, role: credentials.RoleReader}, |
| 55 | {name: "valid connection reader with prefix", connection: s.connectionString, token: defaultToken, role: credentials.RoleReader, prefix: "prefix"}, |
| 56 | {name: "valid connection", connection: s.connectionString, token: defaultToken}, |
| 57 | {name: "valid connection with prefix", connection: s.connectionString, token: defaultToken, prefix: "prefix"}, |
| 58 | } |
| 59 | |
| 60 | for _, tc := range testCases { |
| 61 | s.Run(tc.name, func() { |
| 62 | opts := &vault.NewManagerOpts{AuthToken: tc.token, Address: tc.connection, MountPath: tc.path, Role: tc.role, SecretPrefix: tc.prefix} |
| 63 | _, err := vault.NewManager(opts) |
| 64 | if tc.expectedError { |
| 65 | assert.Error(err) |
| 66 | } else { |
| 67 | assert.NoError(err) |
| 68 | } |
| 69 | }) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | const orgID = "test-org" |
| 74 |
nothing calls this directly
no test coverage detected