|
4 | 4 | "fmt" |
5 | 5 | "strings" |
6 | 6 | "testing" |
7 | | - |
8 | | - "github.com/secrethub/secrethub-go/internals/assert" |
9 | 7 | ) |
10 | 8 |
|
11 | 9 | func TestValidateUsername(t *testing.T) { |
@@ -168,78 +166,3 @@ func TestValidateFullName(t *testing.T) { |
168 | 166 | } |
169 | 167 | } |
170 | 168 | } |
171 | | - |
172 | | -func TestCreateUserRequest_Validate(t *testing.T) { |
173 | | - cases := map[string]struct { |
174 | | - req CreateUserRequest |
175 | | - err error |
176 | | - }{ |
177 | | - "valid using password": { |
178 | | - req: CreateUserRequest{ |
179 | | - Username: "test.-_UserTestT", |
180 | | - Email: "test-account.dev1@secrethub.io", |
181 | | - FullName: "Test Tester", |
182 | | - Password: "hello world", |
183 | | - }, |
184 | | - err: nil, |
185 | | - }, |
186 | | - "valid using credential": { |
187 | | - req: CreateUserRequest{ |
188 | | - Username: "test.-_UserTestT", |
189 | | - Email: "test-account.dev1@secrethub.io", |
190 | | - FullName: "Test Tester", |
191 | | - Credential: &CreateCredentialRequest{ |
192 | | - Type: CredentialTypeKey, |
193 | | - Fingerprint: "88c9eae68eb300b2971a2bec9e5a26ff4179fd661d6b7d861e4c6557b9aaee14", |
194 | | - Verifier: []byte("verifier"), |
195 | | - }, |
196 | | - }, |
197 | | - err: nil, |
198 | | - }, |
199 | | - "invalid no password nor credential": { |
200 | | - req: CreateUserRequest{ |
201 | | - Username: "test.-_UserTestT", |
202 | | - Email: "test-account.dev1@secrethub.io", |
203 | | - FullName: "Test Tester", |
204 | | - }, |
205 | | - err: ErrNoPasswordNorCredential, |
206 | | - }, |
207 | | - "invalid username": { |
208 | | - req: CreateUserRequest{ |
209 | | - Username: "", |
210 | | - Email: "test-account.dev1@secrethub.io", |
211 | | - FullName: "Test Tester", |
212 | | - Password: "hello world", |
213 | | - }, |
214 | | - err: ErrInvalidUsername, |
215 | | - }, |
216 | | - "invalid email": { |
217 | | - req: CreateUserRequest{ |
218 | | - Username: "test", |
219 | | - Email: "notanemail", |
220 | | - FullName: "Test Tester", |
221 | | - Password: "hello world", |
222 | | - }, |
223 | | - err: ErrInvalidEmail, |
224 | | - }, |
225 | | - "invalid full name": { |
226 | | - req: CreateUserRequest{ |
227 | | - Username: "test", |
228 | | - Email: "test-account.dev1@secrethub.io", |
229 | | - FullName: "", |
230 | | - Password: "hello world", |
231 | | - }, |
232 | | - err: ErrInvalidFullName, |
233 | | - }, |
234 | | - } |
235 | | - |
236 | | - for name, tc := range cases { |
237 | | - t.Run(name, func(t *testing.T) { |
238 | | - // Do |
239 | | - err := tc.req.Validate() |
240 | | - |
241 | | - // Assert |
242 | | - assert.Equal(t, err, tc.err) |
243 | | - }) |
244 | | - } |
245 | | -} |
0 commit comments