Mercurial > projects > sievemgr
annotate cmd/sievemgr/internal/config/config_test.go @ 19:854167f55839
Fix SRV record lookup
Do not use a configuration file default value for port in order to detect when
it is not set by the user so that SRV record lookup is triggered.
Depend on version 0.8.1 of go.guido-berhoerster.org/managesieve which contains
an additional necessary fix.
author | Guido Berhoerster <guido+sievemgr@berhoerster.name> |
---|---|
date | Wed, 03 Feb 2021 13:34:44 +0100 |
parents | 4dff4c3f0fbb |
children |
rev | line source |
---|---|
5
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
1 // Copyright (C) 2020 Guido Berhoerster <guido+sievemgr@berhoerster.name> |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
2 // |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
3 // Permission is hereby granted, free of charge, to any person obtaining |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
4 // a copy of this software and associated documentation files (the |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
5 // "Software"), to deal in the Software without restriction, including |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
6 // without limitation the rights to use, copy, modify, merge, publish, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
7 // distribute, sublicense, and/or sell copies of the Software, and to |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
8 // permit persons to whom the Software is furnished to do so, subject to |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
9 // the following conditions: |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
10 // |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
11 // The above copyright notice and this permission notice shall be included |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
12 // in all copies or substantial portions of the Software. |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
13 // |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
17 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
18 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
19 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
20 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
21 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
22 package config_test |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
23 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
24 import ( |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
25 "testing" |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
26 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
27 "go.guido-berhoerster.org/sievemgr/cmd/sievemgr/internal/config" |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
28 ) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
29 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
30 const basicConfig = "\ufeff" + `account "foo" |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
31 host "imap.example.net" |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
32 user "bar@example.net" pass "53cRe7" |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
33 default |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
34 account "local" |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
35 host "localhost" |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
36 port 2000 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
37 insecure |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
38 user "foo" |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
39 pass "s3cR3Et" |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
40 account "bar" host "imap.example.com" user "bar@example.com" pass "53cRe7" |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
41 ` |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
42 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
43 func TestBasicFunctionality(t *testing.T) { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
44 var conf config.Configuration |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
45 if err := config.Parse([]byte(basicConfig), &conf); err != nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
46 t.Fatalf("failed to parse basic config file: %s", err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
47 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
48 if n := len(conf.Accounts); n != 3 { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
49 t.Fatalf("invalid number of parsed accounts, expected 2, got %d", n) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
50 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
51 if conf.Accounts[0].Name != "foo" || |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
52 conf.Accounts[0].Host != "imap.example.net" || |
19
854167f55839
Fix SRV record lookup
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
5
diff
changeset
|
53 conf.Accounts[0].Port != "" || |
5
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
54 conf.Accounts[0].User != "bar@example.net" || |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
55 conf.Accounts[0].Password != "53cRe7" || |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
56 conf.Accounts[0].Insecure { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
57 t.Fatalf(`failed to parse account, expected &main.Account{Name:"foo", Host:"imap.example.net", Port:"4190", User:"bar@example.net", Password:"53cRe7", Insecure:false}, got %#+v`, conf.Accounts[0]) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
58 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
59 if conf.Default == nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
60 t.Fatalf("default account not found") |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
61 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
62 if conf.Default != conf.Accounts[0] { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
63 t.Fatalf("wrong default account, expected \"default\", got %q", conf.Default.Name) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
64 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
65 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
66 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
67 const invalidBOMConfig = "\ufeff\ufeff" + `account "foo" host "imap.example.net" user "bar@example.net" pass "53cRe7" default` |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
68 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
69 func TestInvalidBOM(t *testing.T) { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
70 var conf config.Configuration |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
71 err := config.Parse([]byte(invalidBOMConfig), &conf) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
72 if err == nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
73 t.Fatalf("expected error due to BOM not at the beginning but succeeded") |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
74 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
75 if _, ok := err.(*config.ParserError); !ok { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
76 t.Fatalf("expected config.ParserError, got %T (%q)", err, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
77 err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
78 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
79 t.Logf("reported error: %s", err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
80 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
81 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
82 const invalidUTF8Config = `account "foo"` + "\xff" + ` host "imap.example.net" user "bar@example.net" pass "53cRe7" default` |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
83 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
84 func TestInvalidUTF8(t *testing.T) { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
85 var conf config.Configuration |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
86 err := config.Parse([]byte(invalidUTF8Config), &conf) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
87 if err == nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
88 t.Fatalf("expected error due to invalid UTF-8 but succeeded") |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
89 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
90 if _, ok := err.(*config.ParserError); !ok { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
91 t.Fatalf("expected config.ParserError, got %T (%q)", err, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
92 err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
93 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
94 t.Logf("reported error: %s", err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
95 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
96 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
97 const nulByteConfig = `account "foo` + "\x00" + `" host "imap.example.net" user "bar@example.net" pass "53cRe7" default` |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
98 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
99 func TestNulByte(t *testing.T) { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
100 var conf config.Configuration |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
101 err := config.Parse([]byte(nulByteConfig), &conf) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
102 if err == nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
103 t.Fatalf("expected error due to nul byte but succeeded") |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
104 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
105 if _, ok := err.(*config.ParserError); !ok { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
106 t.Fatalf("expected config.ParserError, got %T (%q)", err, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
107 err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
108 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
109 t.Logf("reported error: %s", err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
110 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
111 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
112 const unexpectedRuneConfig = `account "foo" host "imap.example.net" user "bar@example.net" pass "53cRe7" _in_valid default` |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
113 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
114 func TestInvalidIdentifier(t *testing.T) { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
115 var conf config.Configuration |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
116 err := config.Parse([]byte(unexpectedRuneConfig), &conf) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
117 if err == nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
118 t.Fatalf("expected error due to unexpected rune but succeeded") |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
119 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
120 if _, ok := err.(*config.ParserError); !ok { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
121 t.Fatalf("expected config.ParserError, got %T (%q)", err, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
122 err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
123 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
124 t.Logf("reported error: %s", err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
125 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
126 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
127 const unknownIdentifierConfig = `account "foo" host "imap.example.net" user "bar@example.net" pass "53cRe7" invalid default` |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
128 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
129 func TestUnknownIdentifier(t *testing.T) { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
130 var conf config.Configuration |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
131 err := config.Parse([]byte(unknownIdentifierConfig), &conf) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
132 if err == nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
133 t.Fatalf("expected error due to unknown identifier but succeeded") |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
134 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
135 if _, ok := err.(*config.ParserError); !ok { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
136 t.Fatalf("expected config.ParserError, got %T (%q)", err, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
137 err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
138 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
139 t.Logf("reported error: %s", err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
140 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
141 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
142 const missingWhitespaceConfig = `account "foo" host "imap.example.net" port 2000default user "bar@example.net" pass "53cRe7"` |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
143 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
144 func TestMissingSpace(t *testing.T) { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
145 var conf config.Configuration |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
146 err := config.Parse([]byte(missingWhitespaceConfig), &conf) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
147 if err == nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
148 t.Fatalf("expected error due to missing whitespace between tokens but succeeded") |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
149 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
150 if _, ok := err.(*config.ParserError); !ok { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
151 t.Fatalf("expected config.ParserError, got %T (%q)", err, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
152 err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
153 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
154 t.Logf("reported error: %s", err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
155 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
156 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
157 const missingNameConfig = `account host "imap.example.net" user "bar@example.net" pass "53cRe7" default` |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
158 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
159 func TestMissingName(t *testing.T) { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
160 var conf config.Configuration |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
161 err := config.Parse([]byte(missingNameConfig), &conf) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
162 if err == nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
163 t.Fatalf("expected error due to missing account name but succeeded") |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
164 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
165 if _, ok := err.(*config.ParserError); !ok { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
166 t.Fatalf("expected config.ParserError, got %T (%q)", err, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
167 err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
168 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
169 t.Logf("reported error: %s", err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
170 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
171 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
172 const invalidTypeConfig = `account 1234 host "imap.example.net" user "bar@example.net" pass "53cRe7"` |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
173 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
174 func TestInvalidType(t *testing.T) { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
175 var conf config.Configuration |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
176 err := config.Parse([]byte(invalidTypeConfig), &conf) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
177 if err == nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
178 t.Fatalf("expected error due to invalid type but succeeded") |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
179 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
180 if _, ok := err.(*config.ParserError); !ok { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
181 t.Fatalf("expected config.ParserError, got %T (%q)", err, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
182 err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
183 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
184 t.Logf("reported error: %s", err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
185 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
186 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
187 const unterminatedStringConfig = `account "foo" host "imap.example.net" user "bar@example.net" pass "53cRe7 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
188 account "bar" host "imap.example.com" user "bar@example.com" pass "53cRe7" |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
189 ` |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
190 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
191 func TestUnterminatedString(t *testing.T) { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
192 var conf config.Configuration |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
193 err := config.Parse([]byte(unterminatedStringConfig), &conf) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
194 if err == nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
195 t.Fatalf("expected error due to an unterminated string but succeeded") |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
196 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
197 if _, ok := err.(*config.ParserError); !ok { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
198 t.Fatalf("expected config.ParserError, got %T (%q)", err, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
199 err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
200 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
201 t.Logf("reported error: %s", err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
202 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
203 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
204 const unexpectedEOFConfig = `account "foo" host "imap.example.net" user "bar@example.net" pass ` |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
205 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
206 func TestUnexpectedEOF(t *testing.T) { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
207 var conf config.Configuration |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
208 err := config.Parse([]byte(unexpectedEOFConfig), &conf) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
209 if err == nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
210 t.Fatalf("expected error due to an unterminated string but succeeded") |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
211 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
212 if _, ok := err.(*config.ParserError); !ok { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
213 t.Fatalf("expected config.ParserError, got %T (%q)", err, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
214 err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
215 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
216 t.Logf("reported error: %s", err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
217 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
218 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
219 const missingHostConfig = `account "foo" user "bar@example.net" pass "53cRe7"` |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
220 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
221 func TestMissingHost(t *testing.T) { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
222 var conf config.Configuration |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
223 err := config.Parse([]byte(missingHostConfig), &conf) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
224 if err == nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
225 t.Fatalf("expected error due to missing host but succeeded") |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
226 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
227 if _, ok := err.(*config.ParserError); !ok { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
228 t.Fatalf("expected config.ParserError, got %T (%q)", err, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
229 err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
230 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
231 t.Logf("reported error: %s", err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
232 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
233 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
234 const missingUserConfig = `account "foo" host "imap.example.net" user "" pass "53cRe7"` |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
235 |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
236 func TestMissingUser(t *testing.T) { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
237 var conf config.Configuration |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
238 err := config.Parse([]byte(missingUserConfig), &conf) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
239 if err == nil { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
240 t.Fatalf("expected error due to missing user but succeeded") |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
241 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
242 if _, ok := err.(*config.ParserError); !ok { |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
243 t.Fatalf("expected config.ParserError, got %T (%q)", err, |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
244 err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
245 } |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
246 t.Logf("reported error: %s", err) |
4dff4c3f0fbb
Introduce configuration file where account information is specified
Guido Berhoerster <guido+sievemgr@berhoerster.name>
parents:
diff
changeset
|
247 } |