|
7 | 7 | "path/filepath"
|
8 | 8 | "reflect"
|
9 | 9 | "strconv"
|
| 10 | + "strings" |
10 | 11 |
|
11 | 12 | . "github.com/onsi/ginkgo"
|
12 | 13 | . "github.com/onsi/gomega"
|
@@ -250,6 +251,64 @@ var _ = Describe("mailbox add/delete", func() {
|
250 | 251 | }
|
251 | 252 | })
|
252 | 253 |
|
| 254 | + It("can't add an mailbox if an alias with same email exists", func() { |
| 255 | + if skipMailboxAddDelete && !isCI { |
| 256 | + Skip("can't add an mailbox if an alias with same email exists") |
| 257 | + } |
| 258 | + |
| 259 | + cli := exec.Command(cliPath, "alias", "add", mailboxName1) |
| 260 | + output, err := cli.CombinedOutput() |
| 261 | + if err != nil { |
| 262 | + Fail(string(output)) |
| 263 | + } |
| 264 | + |
| 265 | + cli = exec.Command(cliPath, "mailbox", "add", mailboxName1, mailboxPW) |
| 266 | + output, err = cli.CombinedOutput() |
| 267 | + if err == nil { |
| 268 | + Fail("Expect an error") |
| 269 | + } |
| 270 | + actual := string(output) |
| 271 | + expected := fmt.Sprintf("An alias %s already exists\n", mailboxName1) |
| 272 | + |
| 273 | + if !reflect.DeepEqual(actual, expected) { |
| 274 | + Fail(fmt.Sprintf("actual = %s, expected = %s", actual, expected)) |
| 275 | + } |
| 276 | + }) |
| 277 | + |
| 278 | + It("can't add an mailbox if an mailbox alias with same email exists", func() { |
| 279 | + if skipMailboxAddDelete && !isCI { |
| 280 | + Skip("can't add an mailbox if an mailbox alias with same email exists") |
| 281 | + } |
| 282 | + |
| 283 | + splitMail := strings.Split(mailboxName1, "@") |
| 284 | + name, domain := splitMail[0], splitMail[1] |
| 285 | + mailboxName := "othername@" + domain |
| 286 | + |
| 287 | + cli := exec.Command(cliPath, "mailbox", "add", mailboxName, mailboxPW) |
| 288 | + output, err := cli.CombinedOutput() |
| 289 | + if err != nil { |
| 290 | + Fail(string(output)) |
| 291 | + } |
| 292 | + |
| 293 | + cli = exec.Command(cliPath, "mailbox", "add-alias", name, mailboxName) |
| 294 | + output, err = cli.CombinedOutput() |
| 295 | + if err != nil { |
| 296 | + Fail(string(output)) |
| 297 | + } |
| 298 | + |
| 299 | + cli = exec.Command(cliPath, "mailbox", "add", mailboxName1, mailboxPW) |
| 300 | + output, err = cli.CombinedOutput() |
| 301 | + if err == nil { |
| 302 | + Fail("Expect an error") |
| 303 | + } |
| 304 | + actual := string(output) |
| 305 | + expected := fmt.Sprintf("A mailbox alias %s already exists\n", mailboxName1) |
| 306 | + |
| 307 | + if !reflect.DeepEqual(actual, expected) { |
| 308 | + Fail(fmt.Sprintf("actual = %s, expected = %s", actual, expected)) |
| 309 | + } |
| 310 | + }) |
| 311 | + |
253 | 312 | It("can add an mailbox with custom quota", func() {
|
254 | 313 | if skipMailboxAddDelete && !isCI {
|
255 | 314 | Skip("can add an mailbox with custom quota")
|
|
0 commit comments