Mercurial > vim
comparison src/testdir/test_crypt.vim @ 25168:68f0093134b1 v8.2.3120
patch 8.2.3120: crypt with sodium test fails on MS-Windows
Commit: https://github.com/vim/vim/commit/db8647277082a8a69a189ded8bd1408af993b54e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jul 8 11:37:50 2021 +0200
patch 8.2.3120: crypt with sodium test fails on MS-Windows
Problem: Crypt with sodium test fails on MS-Windows.
Solution: Make the tests pass. (closes https://github.com/vim/vim/issues/8428)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 08 Jul 2021 11:45:04 +0200 |
parents | 7e9e53a0368f |
children | 1ef6880ba4a9 |
comparison
equal
deleted
inserted
replaced
25167:92b0acab7286 | 25168:68f0093134b1 |
---|---|
122 call Uncrypt_stable_xxd('xchacha20', hex, "sodium_crypt", ["abcdefghijklmnopqrstuvwxyzäöü", "ZZZ_äüöÄÜÖ_!@#$%^&*()_+=-`~"]) | 122 call Uncrypt_stable_xxd('xchacha20', hex, "sodium_crypt", ["abcdefghijklmnopqrstuvwxyzäöü", "ZZZ_äüöÄÜÖ_!@#$%^&*()_+=-`~"]) |
123 endfunc | 123 endfunc |
124 | 124 |
125 func Test_uncrypt_xchacha20_invalid() | 125 func Test_uncrypt_xchacha20_invalid() |
126 CheckFeature sodium | 126 CheckFeature sodium |
127 | |
127 " load an invalid encrypted file and verify it can be decrypted with an | 128 " load an invalid encrypted file and verify it can be decrypted with an |
128 " error message | 129 " error message |
129 try | 130 try |
130 call feedkeys(":split samples/crypt_sodium_invalid.txt\<CR>sodium\<CR>", 'xt') | 131 call feedkeys(":split samples/crypt_sodium_invalid.txt\<CR>sodium\<CR>", 'xt') |
131 call assert_false(1, 'should not happen') | 132 call assert_false(1, 'should not happen') |
140 bw! | 141 bw! |
141 endfunc | 142 endfunc |
142 | 143 |
143 func Test_uncrypt_xchacha20_2() | 144 func Test_uncrypt_xchacha20_2() |
144 CheckFeature sodium | 145 CheckFeature sodium |
146 | |
145 sp Xcrypt_sodium.txt | 147 sp Xcrypt_sodium.txt |
146 " Create a larger file, so that Vim will write in several blocks | 148 " Create a larger file, so that Vim will write in several blocks |
147 call setline(1, range(1,4000)) | 149 call setline(1, range(1,4000)) |
148 call assert_equal(1, &swapfile) | 150 call assert_equal(1, &swapfile) |
149 set cryptmethod=xchacha20 | 151 set cryptmethod=xchacha20 |
157 bw! | 159 bw! |
158 call feedkeys(":sp Xcrypt_sodium.txt\<CR>sodium\<CR>", 'xt') | 160 call feedkeys(":sp Xcrypt_sodium.txt\<CR>sodium\<CR>", 'xt') |
159 " successfully decrypted | 161 " successfully decrypted |
160 call assert_equal(range(1, 4000)->map( {_, v -> string(v)}), getline(1,'$')) | 162 call assert_equal(range(1, 4000)->map( {_, v -> string(v)}), getline(1,'$')) |
161 set key= | 163 set key= |
162 w! | 164 w! ++ff=unix |
163 " enryption removed | 165 " enryption removed |
164 call assert_match('"Xcrypt_sodium.txt" 4000L, 18893B written', execute(':message')) | 166 call assert_match('"Xcrypt_sodium.txt" 4000L, 18893B written', execute(':message')) |
165 bw! | 167 bw! |
166 call delete('Xcrypt_sodium.txt') | 168 call delete('Xcrypt_sodium.txt') |
167 set cryptmethod&vim | 169 set cryptmethod&vim |
168 endfunc | 170 endfunc |
169 | 171 |
170 func Test_uncrypt_xchacha20_3_persistent_undo() | 172 func Test_uncrypt_xchacha20_3_persistent_undo() |
171 CheckFeature sodium | 173 CheckFeature sodium |
172 CheckFeature persistent_undo | 174 CheckFeature persistent_undo |
175 | |
173 sp Xcrypt_sodium_undo.txt | 176 sp Xcrypt_sodium_undo.txt |
174 set cryptmethod=xchacha20 undofile | 177 set cryptmethod=xchacha20 undofile |
175 call feedkeys(":X\<CR>sodium\<CR>sodium\<CR>", 'xt') | 178 call feedkeys(":X\<CR>sodium\<CR>sodium\<CR>", 'xt') |
176 call assert_equal(0, &undofile) | 179 call assert_equal(0, &undofile) |
177 let ufile=undofile(@%) | 180 let ufile=undofile(@%) |
189 bw! | 192 bw! |
190 call feedkeys(":sp Xcrypt_sodium_undo.txt\<CR>sodium\<CR>", 'xt') | 193 call feedkeys(":sp Xcrypt_sodium_undo.txt\<CR>sodium\<CR>", 'xt') |
191 " should fail | 194 " should fail |
192 norm! u | 195 norm! u |
193 call assert_match('Already at oldest change', execute(':1mess')) | 196 call assert_match('Already at oldest change', execute(':1mess')) |
194 call assert_fails('verbose rundo' .. fnameescape(ufile), 'E822') | 197 call assert_fails('verbose rundo ' .. fnameescape(ufile), 'E822') |
195 bw! | 198 bw! |
196 set undolevels& cryptmethod& undofile& | 199 set undolevels& cryptmethod& undofile& |
197 call delete('Xcrypt_sodium_undo.txt') | 200 call delete('Xcrypt_sodium_undo.txt') |
198 endfunc | 201 endfunc |
199 | 202 |