blob: 944b69dc523179822054b0257fa439fcdd831575 [file] [log] [blame]
Bram Moolenaar40e6a712010-05-16 22:32:54 +02001Test for encryption.
Bram Moolenaar72fe56f2013-07-01 21:00:35 +02002The test data is in another file to avoid problems with 'encoding', especially
3cp932.
Bram Moolenaar40e6a712010-05-16 22:32:54 +02004
5STARTTEST
6:so small.vim
Bram Moolenaar72fe56f2013-07-01 21:00:35 +02007:set enc=latin1
8:bwipe!
9:r test71a.in
Bram Moolenaarf50a2532010-05-21 15:36:08 +020010:/^start of text/+1
11:let text_lines = getline('.', line('.') + 2)
Bram Moolenaar49771f42010-07-20 17:32:38 +020012:/^start of cm=zip bytes/+1
Bram Moolenaarf50a2532010-05-21 15:36:08 +020013:let cm0_bytes = getline('.', '.')
Bram Moolenaar49771f42010-07-20 17:32:38 +020014:/^start of cm=blowfish bytes/+1
Bram Moolenaarf50a2532010-05-21 15:36:08 +020015:let cm1_bytes = getline('.', '.')
Bram Moolenaar8f4ac012014-08-10 13:38:34 +020016:/^start of cm=blowfish2 bytes/+1
17:let cm2_bytes = getline('.', '.')
Bram Moolenaard73895e2013-06-19 21:17:31 +020018:bwipe!
Bram Moolenaarf50a2532010-05-21 15:36:08 +020019:call append(0, text_lines)
Bram Moolenaar40e6a712010-05-16 22:32:54 +020020:$d
21:X
22foobar
23foobar
24:w! Xtestfile
25:bwipe!
26:e Xtestfile
27foobar
Bram Moolenaarf50a2532010-05-21 15:36:08 +020028:let cm0_read_back = getline('.', '$')
Bram Moolenaar40e6a712010-05-16 22:32:54 +020029:set key=
Bram Moolenaar49771f42010-07-20 17:32:38 +020030:set cryptmethod=blowfish
31:" If the blowfish test fails 'cryptmethod' will be 'zip' now.
32:%s/^/\=&cryptmethod == 'blowfish' ? "OK " : "blowfish test failed "/
Bram Moolenaar40e6a712010-05-16 22:32:54 +020033:X
34barfoo
35barfoo
36:w! Xtestfile
37:bwipe!
38:e Xtestfile
39barfoo
Bram Moolenaarf50a2532010-05-21 15:36:08 +020040:let cm1_read_back = getline('.', '$')
Bram Moolenaar8f4ac012014-08-10 13:38:34 +020041:set key=
42:set cryptmethod=blowfish2
43:" If the blowfish test fails 'cryptmethod' will be 'zip' now.
44:%s/^/\=&cryptmethod == 'blowfish2' ? "OK " : "blowfish test failed "/
45:X
46bar2foo
47bar2foo
48:w! Xtestfile
49:bwipe!
50:e Xtestfile
51bar2foo
52:let cm2_read_back = getline('.', '$')
Bram Moolenaarf50a2532010-05-21 15:36:08 +020053:bwipe!
54:set bin noeol key=
55:call append(0, cm0_bytes)
56:$d
57:set fenc=latin1
58:w! Xtestfile
59:bwipe!
60:set nobin
61:e Xtestfile
62foofoo
63:let cm0_read_bin = getline('.', '$')
64:bwipe!
65:set bin noeol key=
66:call append(0, cm1_bytes)
67:$d
68:set fenc=latin1
69:w! Xtestfile
70:bwipe!
71:set nobin
72:e Xtestfile
73barbar
Bram Moolenaar8f4ac012014-08-10 13:38:34 +020074:let cm1_read_bin = getline('.', '$')
75:bwipe!
76:set bin noeol key=
77:call append(0, cm2_bytes)
78:$d
79:set fenc=latin1
80:w! Xtestfile
81:bwipe!
82:set nobin
83:e Xtestfile
84barburp
85:call append(0, cm1_read_bin)
Bram Moolenaarf50a2532010-05-21 15:36:08 +020086:call append(0, cm0_read_bin)
Bram Moolenaar8f4ac012014-08-10 13:38:34 +020087:call append(0, cm2_read_back)
Bram Moolenaarf50a2532010-05-21 15:36:08 +020088:call append(0, cm1_read_back)
89:call append(0, cm0_read_back)
90:set key= fenc=latin1
Bram Moolenaar40e6a712010-05-16 22:32:54 +020091:w! test.out
92:qa!
93ENDTEST
94