|
| 1 | +import { Test } from '../Type' |
| 2 | +import { v2 } from '../../../../lib/index.js' |
| 3 | +import { starter, propfind } from './.createFiles' |
| 4 | + |
| 5 | +export default ((info, isValid) => |
| 6 | +{ |
| 7 | + info.init(11); |
| 8 | + |
| 9 | + starter(info, isValid, (s) => { |
| 10 | + propfind(s, info, 'folder', v2.HTTPCodes.MultiStatus, 0, undefined, (xml) => { |
| 11 | + const props = xml.find('DAV:multistatus').find('DAV:response').find('DAV:propstat').find('DAV:prop'); |
| 12 | + const available = parseInt(props.find('DAV:quota-available-bytes').findText()); |
| 13 | + const used = parseInt(props.find('DAV:quota-used-bytes').findText()); |
| 14 | + |
| 15 | + if(available !== 100) |
| 16 | + return isValid(false, 'The "DAV:quota-available-bytes" must be equals to 100'); |
| 17 | + if(used > 0) |
| 18 | + return isValid(false, 'The "DAV:quota-used-bytes" must contains 0'); |
| 19 | + |
| 20 | + isValid(true); |
| 21 | + }) |
| 22 | + }); |
| 23 | + |
| 24 | + starter(info, isValid, (s) => { |
| 25 | + propfind(s, info, 'file', v2.HTTPCodes.MultiStatus, 0, undefined, (xml) => { |
| 26 | + const props = xml.find('DAV:multistatus').find('DAV:response').find('DAV:propstat').find('DAV:prop'); |
| 27 | + const available = parseInt(props.find('DAV:quota-available-bytes').findText()); |
| 28 | + const used = parseInt(props.find('DAV:quota-used-bytes').findText()); |
| 29 | + |
| 30 | + if(available !== 100) |
| 31 | + return isValid(false, 'The "DAV:quota-available-bytes" must be equals to 100'); |
| 32 | + if(used > 0) |
| 33 | + return isValid(false, 'The "DAV:quota-used-bytes" must contains 0'); |
| 34 | + |
| 35 | + isValid(true); |
| 36 | + }) |
| 37 | + }); |
| 38 | + |
| 39 | + starter(info, isValid, (s) => { |
| 40 | + info.req({ |
| 41 | + url: 'http://localhost:' + s.options.port + '/file2', |
| 42 | + method: 'PUT' |
| 43 | + }, v2.HTTPCodes.Created, () => { |
| 44 | + propfind(s, info, 'file2', v2.HTTPCodes.MultiStatus, 0, undefined, (xml) => { |
| 45 | + const props = xml.find('DAV:multistatus').find('DAV:response').find('DAV:propstat').find('DAV:prop'); |
| 46 | + const available = parseInt(props.find('DAV:quota-available-bytes').findText()); |
| 47 | + const used = parseInt(props.find('DAV:quota-used-bytes').findText()); |
| 48 | + |
| 49 | + if(available >= 100) |
| 50 | + return isValid(false, 'The "DAV:quota-available-bytes" must be lesser than 100'); |
| 51 | + if(used <= 0) |
| 52 | + return isValid(false, 'The "DAV:quota-used-bytes" must contains a value greater than 0'); |
| 53 | + |
| 54 | + isValid(true); |
| 55 | + }) |
| 56 | + }) |
| 57 | + }); |
| 58 | + |
| 59 | + starter(info, isValid, (s) => { |
| 60 | + info.req({ |
| 61 | + url: 'http://localhost:' + s.options.port + '/folder/file', |
| 62 | + method: 'PUT' |
| 63 | + }, v2.HTTPCodes.Created, () => { |
| 64 | + propfind(s, info, 'folder/file', v2.HTTPCodes.MultiStatus, 0, undefined, (xml) => { |
| 65 | + const props = xml.find('DAV:multistatus').find('DAV:response').find('DAV:propstat').find('DAV:prop'); |
| 66 | + const available = parseInt(props.find('DAV:quota-available-bytes').findText()); |
| 67 | + const used = parseInt(props.find('DAV:quota-used-bytes').findText()); |
| 68 | + |
| 69 | + if(available >= 100) |
| 70 | + return isValid(false, 'The "DAV:quota-available-bytes" must be lesser than 100'); |
| 71 | + if(used <= 0) |
| 72 | + return isValid(false, 'The "DAV:quota-used-bytes" must contains a value greater than 0'); |
| 73 | + |
| 74 | + isValid(true); |
| 75 | + }) |
| 76 | + }) |
| 77 | + }); |
| 78 | + |
| 79 | + starter(info, isValid, (s) => { |
| 80 | + info.req({ |
| 81 | + url: 'http://localhost:' + s.options.port + '/folder2', |
| 82 | + method: 'MKCOL' |
| 83 | + }, v2.HTTPCodes.Created, () => { |
| 84 | + propfind(s, info, 'folder2', v2.HTTPCodes.MultiStatus, 0, undefined, (xml) => { |
| 85 | + const props = xml.find('DAV:multistatus').find('DAV:response').find('DAV:propstat').find('DAV:prop'); |
| 86 | + const available = parseInt(props.find('DAV:quota-available-bytes').findText()); |
| 87 | + const used = parseInt(props.find('DAV:quota-used-bytes').findText()); |
| 88 | + |
| 89 | + if(available >= 100) |
| 90 | + return isValid(false, 'The "DAV:quota-available-bytes" must be lesser than 100'); |
| 91 | + if(used <= 0) |
| 92 | + return isValid(false, 'The "DAV:quota-used-bytes" must contains a value greater than 0'); |
| 93 | + |
| 94 | + isValid(true); |
| 95 | + }) |
| 96 | + }) |
| 97 | + }); |
| 98 | + |
| 99 | + starter(info, isValid, (s) => { |
| 100 | + info.req({ |
| 101 | + url: 'http://localhost:' + s.options.port + '/folder/folder', |
| 102 | + method: 'MKCOL' |
| 103 | + }, v2.HTTPCodes.Created, () => { |
| 104 | + propfind(s, info, 'folder/folder', v2.HTTPCodes.MultiStatus, 0, undefined, (xml) => { |
| 105 | + const props = xml.find('DAV:multistatus').find('DAV:response').find('DAV:propstat').find('DAV:prop'); |
| 106 | + const available = parseInt(props.find('DAV:quota-available-bytes').findText()); |
| 107 | + const used = parseInt(props.find('DAV:quota-used-bytes').findText()); |
| 108 | + |
| 109 | + if(available >= 100) |
| 110 | + return isValid(false, 'The "DAV:quota-available-bytes" must be lesser than 100'); |
| 111 | + if(used <= 0) |
| 112 | + return isValid(false, 'The "DAV:quota-used-bytes" must contains a value greater than 0'); |
| 113 | + |
| 114 | + isValid(true); |
| 115 | + }) |
| 116 | + }) |
| 117 | + }); |
| 118 | + |
| 119 | + let content = ''; |
| 120 | + for(let i = 0; i < 1000; ++i) |
| 121 | + content += 'A'; |
| 122 | + |
| 123 | + starter(info, isValid, (s) => { |
| 124 | + info.req({ |
| 125 | + url: 'http://localhost:' + s.options.port + '/file2', |
| 126 | + method: 'PUT', |
| 127 | + body: content |
| 128 | + }, v2.HTTPCodes.InsufficientStorage, () => { |
| 129 | + isValid(true); |
| 130 | + }) |
| 131 | + }); |
| 132 | + |
| 133 | + let content2 = ''; |
| 134 | + for(let i = 0; i < 100; ++i) |
| 135 | + content2 += 'A'; |
| 136 | + |
| 137 | + starter(info, isValid, (s) => { |
| 138 | + info.req({ |
| 139 | + url: 'http://localhost:' + s.options.port + '/file', |
| 140 | + method: 'PUT', |
| 141 | + body: content2 |
| 142 | + }, v2.HTTPCodes.OK, () => { |
| 143 | + isValid(true); |
| 144 | + }) |
| 145 | + }); |
| 146 | + |
| 147 | + let content3 = ''; |
| 148 | + for(let i = 0; i < 99; ++i) |
| 149 | + content3 += 'A'; |
| 150 | + |
| 151 | + starter(info, isValid, (s) => { |
| 152 | + info.req({ |
| 153 | + url: 'http://localhost:' + s.options.port + '/file', |
| 154 | + method: 'PUT', |
| 155 | + body: content3 |
| 156 | + }, v2.HTTPCodes.OK, () => { |
| 157 | + let content4 = ''; |
| 158 | + for(let i = 0; i < 99; ++i) |
| 159 | + content4 += 'A'; |
| 160 | + |
| 161 | + starter(info, isValid, (s) => { |
| 162 | + info.req({ |
| 163 | + url: 'http://localhost:' + s.options.port + '/file', |
| 164 | + method: 'PUT', |
| 165 | + body: content4 |
| 166 | + }, v2.HTTPCodes.OK, () => { |
| 167 | + isValid(true); |
| 168 | + }) |
| 169 | + }); |
| 170 | + }) |
| 171 | + }); |
| 172 | + |
| 173 | + let content5 = ''; |
| 174 | + for(let i = 0; i < 100; ++i) |
| 175 | + content5 += 'A'; |
| 176 | + |
| 177 | + starter(info, isValid, (s) => { |
| 178 | + info.reqStream({ |
| 179 | + url: 'http://localhost:' + s.options.port + '/file', |
| 180 | + method: 'PUT' |
| 181 | + }, (res) => { |
| 182 | + isValid(res.statusCode === v2.HTTPCodes.OK); |
| 183 | + }).end(content5); |
| 184 | + }); |
| 185 | + |
| 186 | + let content6 = ''; |
| 187 | + for(let i = 0; i < 1000; ++i) |
| 188 | + content6 += 'A'; |
| 189 | + |
| 190 | + starter(info, isValid, (s) => { |
| 191 | + info.reqStream({ |
| 192 | + url: 'http://localhost:' + s.options.port + '/file', |
| 193 | + method: 'PUT', |
| 194 | + canFail: true |
| 195 | + }, (res) => { |
| 196 | + isValid(res.statusCode === v2.HTTPCodes.InsufficientStorage); |
| 197 | + }).end(content6); |
| 198 | + }); |
| 199 | + |
| 200 | +}) as Test; |
0 commit comments