2020-02-16 09:03:03 -05:00
/ * e s l i n t - d i s a b l e
no - unused - vars ,
* /
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
2020-02-16 09:03:02 -05:00
/ *
* decaffeinate suggestions :
* DS101 : Remove unnecessary use of Array . from
* DS102 : Remove unnecessary code created because of implicit returns
* DS207 : Consider shorter variations of null checks
* Full docs : https : //github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
* /
2021-08-03 05:00:44 -04:00
2021-07-12 12:47:20 -04:00
const Settings = require ( '@overleaf/settings' )
2021-03-12 17:16:01 -05:00
const { expect } = require ( 'chai' )
2020-08-28 08:13:19 -04:00
const { db , ObjectId } = require ( '../../../app/js/mongodb' )
2020-02-16 09:03:09 -05:00
const async = require ( 'async' )
const DocstoreApp = require ( './helpers/DocstoreApp' )
const DocstoreClient = require ( './helpers/DocstoreClient' )
2020-07-23 14:43:33 -04:00
const { Storage } = require ( '@google-cloud/storage' )
const Persistor = require ( '../../../app/js/PersistorManager' )
2023-06-01 07:38:45 -04:00
const { ReadableString } = require ( '@overleaf/stream-utils' )
2020-07-23 14:43:33 -04:00
function uploadContent ( path , json , callback ) {
2023-06-01 07:38:45 -04:00
const stream = new ReadableString ( JSON . stringify ( json ) )
2020-07-23 14:43:33 -04:00
Persistor . sendStream ( Settings . docstore . bucket , path , stream )
. then ( ( ) => callback ( ) )
. catch ( callback )
}
2017-03-09 13:18:50 -05:00
2020-05-28 09:20:54 -04:00
describe ( 'Archiving' , function ( ) {
before ( function ( done ) {
2020-02-16 09:03:09 -05:00
return DocstoreApp . ensureRunning ( done )
} )
2020-07-23 14:43:33 -04:00
before ( async function ( ) {
const storage = new Storage ( Settings . docstore . gcs . endpoint )
await storage . createBucket ( Settings . docstore . bucket )
await storage . createBucket ( ` ${ Settings . docstore . bucket } -deleted ` )
} )
2023-07-21 07:04:10 -04:00
after ( async function ( ) {
// Tear down the buckets created above
const storage = new Storage ( Settings . docstore . gcs . endpoint )
await storage . bucket ( Settings . docstore . bucket ) . deleteFiles ( )
await storage . bucket ( Settings . docstore . bucket ) . delete ( )
await storage . bucket ( ` ${ Settings . docstore . bucket } -deleted ` ) . deleteFiles ( )
await storage . bucket ( ` ${ Settings . docstore . bucket } -deleted ` ) . delete ( )
} )
2020-05-28 09:20:54 -04:00
describe ( 'multiple docs in a project' , function ( ) {
before ( function ( done ) {
2023-12-13 04:38:54 -05:00
this . project _id = new ObjectId ( )
2020-02-16 09:03:09 -05:00
this . docs = [
{
2023-12-13 04:38:54 -05:00
_id : new ObjectId ( ) ,
2020-02-16 09:03:09 -05:00
lines : [ 'one' , 'two' , 'three' ] ,
ranges : { } ,
2021-07-13 07:04:48 -04:00
version : 2 ,
2020-02-16 09:03:09 -05:00
} ,
{
2023-12-13 04:38:54 -05:00
_id : new ObjectId ( ) ,
2020-02-16 09:03:09 -05:00
lines : [ 'aaa' , 'bbb' , 'ccc' ] ,
ranges : { } ,
2021-07-13 07:04:48 -04:00
version : 4 ,
} ,
2020-02-16 09:03:09 -05:00
]
2021-07-13 07:04:48 -04:00
const jobs = Array . from ( this . docs ) . map ( doc =>
( doc => {
return callback => {
2020-02-16 09:03:09 -05:00
return DocstoreClient . createDoc (
this . project _id ,
doc . _id ,
doc . lines ,
doc . version ,
doc . ranges ,
callback
)
}
} ) ( doc )
)
2021-07-13 07:04:48 -04:00
return async . series ( jobs , error => {
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
return DocstoreClient . archiveAllDoc ( this . project _id , ( error , res ) => {
2021-10-27 05:49:18 -04:00
if ( error ) return done ( error )
2020-02-16 09:03:09 -05:00
this . res = res
return done ( )
} )
} )
} )
2020-05-28 09:20:54 -04:00
it ( 'should archive all the docs' , function ( done ) {
2020-02-16 09:03:09 -05:00
this . res . statusCode . should . equal ( 204 )
return done ( )
} )
2020-05-28 09:20:54 -04:00
it ( 'should set inS3 and unset lines and ranges in each doc' , function ( done ) {
2021-07-13 07:04:48 -04:00
const jobs = Array . from ( this . docs ) . map ( doc =>
( doc => {
return callback => {
2020-02-16 09:03:09 -05:00
return db . docs . findOne ( { _id : doc . _id } , ( error , doc ) => {
2021-10-27 05:49:18 -04:00
if ( error ) return callback ( error )
2021-03-12 17:16:01 -05:00
expect ( doc . lines ) . not . to . exist
expect ( doc . ranges ) . not . to . exist
2020-02-16 09:03:09 -05:00
doc . inS3 . should . equal ( true )
return callback ( )
} )
}
} ) ( doc )
)
return async . series ( jobs , done )
} )
2020-05-28 09:20:54 -04:00
it ( 'should set the docs in s3 correctly' , function ( done ) {
2021-07-13 07:04:48 -04:00
const jobs = Array . from ( this . docs ) . map ( doc =>
( doc => {
return callback => {
2020-02-16 09:03:09 -05:00
return DocstoreClient . getS3Doc (
this . project _id ,
doc . _id ,
2023-03-16 07:58:12 -04:00
( error , s3Doc ) => {
2021-10-27 05:49:18 -04:00
if ( error ) return callback ( error )
2023-03-16 07:58:12 -04:00
s3Doc . lines . should . deep . equal ( doc . lines )
s3Doc . ranges . should . deep . equal ( doc . ranges )
2020-07-23 14:43:33 -04:00
callback ( )
2020-02-16 09:03:09 -05:00
}
)
}
} ) ( doc )
)
return async . series ( jobs , done )
} )
2020-05-28 09:20:54 -04:00
return describe ( 'after unarchiving from a request for the project' , function ( ) {
before ( function ( done ) {
2020-02-16 09:03:09 -05:00
return DocstoreClient . getAllDocs (
this . project _id ,
2023-03-16 07:58:12 -04:00
( error , res , fetchedDocs ) => {
this . fetched _docs = fetchedDocs
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
return done ( )
}
)
} )
2020-05-28 09:20:54 -04:00
it ( 'should return the docs' , function ( done ) {
2020-02-16 09:03:09 -05:00
for ( let i = 0 ; i < this . fetched _docs . length ; i ++ ) {
const doc = this . fetched _docs [ i ]
doc . lines . should . deep . equal ( this . docs [ i ] . lines )
}
return done ( )
} )
2020-05-28 09:20:54 -04:00
return it ( 'should restore the docs to mongo' , function ( done ) {
2020-02-16 09:03:09 -05:00
const jobs = Array . from ( this . docs ) . map ( ( doc , i ) =>
( ( doc , i ) => {
2021-07-13 07:04:48 -04:00
return callback => {
2020-02-16 09:03:09 -05:00
return db . docs . findOne ( { _id : doc . _id } , ( error , doc ) => {
2021-10-27 05:49:18 -04:00
if ( error ) return callback ( error )
2020-02-16 09:03:09 -05:00
doc . lines . should . deep . equal ( this . docs [ i ] . lines )
doc . ranges . should . deep . equal ( this . docs [ i ] . ranges )
2021-03-12 17:16:01 -05:00
expect ( doc . inS3 ) . not . to . exist
2020-02-16 09:03:09 -05:00
return callback ( )
} )
}
} ) ( doc , i )
)
return async . series ( jobs , done )
} )
} )
} )
2020-05-28 09:20:54 -04:00
describe ( 'a deleted doc' , function ( ) {
2021-01-04 12:04:33 -05:00
beforeEach ( function ( done ) {
2023-12-13 04:38:54 -05:00
this . project _id = new ObjectId ( )
2020-02-16 09:03:09 -05:00
this . doc = {
2023-12-13 04:38:54 -05:00
_id : new ObjectId ( ) ,
2020-02-16 09:03:09 -05:00
lines : [ 'one' , 'two' , 'three' ] ,
ranges : { } ,
2021-07-13 07:04:48 -04:00
version : 2 ,
2020-02-16 09:03:09 -05:00
}
return DocstoreClient . createDoc (
this . project _id ,
this . doc . _id ,
this . doc . lines ,
this . doc . version ,
this . doc . ranges ,
2021-07-13 07:04:48 -04:00
error => {
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
return DocstoreClient . deleteDoc (
this . project _id ,
this . doc . _id ,
2021-07-13 07:04:48 -04:00
error => {
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
return DocstoreClient . archiveAllDoc (
this . project _id ,
( error , res ) => {
this . res = res
if ( error != null ) {
throw error
}
return done ( )
}
)
}
)
}
)
} )
2020-05-28 09:20:54 -04:00
it ( 'should successully archive the docs' , function ( done ) {
2020-02-16 09:03:09 -05:00
this . res . statusCode . should . equal ( 204 )
return done ( )
} )
2020-05-28 09:20:54 -04:00
it ( 'should set inS3 and unset lines and ranges in each doc' , function ( done ) {
2020-02-16 09:03:09 -05:00
return db . docs . findOne ( { _id : this . doc . _id } , ( error , doc ) => {
if ( error != null ) {
throw error
}
2021-03-12 17:16:01 -05:00
expect ( doc . lines ) . not . to . exist
expect ( doc . ranges ) . not . to . exist
2020-02-16 09:03:09 -05:00
doc . inS3 . should . equal ( true )
doc . deleted . should . equal ( true )
return done ( )
} )
} )
2020-05-28 09:20:54 -04:00
it ( 'should set the doc in s3 correctly' , function ( done ) {
2020-02-16 09:03:09 -05:00
return DocstoreClient . getS3Doc (
this . project _id ,
this . doc . _id ,
2023-03-16 07:58:12 -04:00
( error , s3Doc ) => {
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
2023-03-16 07:58:12 -04:00
s3Doc . lines . should . deep . equal ( this . doc . lines )
s3Doc . ranges . should . deep . equal ( this . doc . ranges )
2020-02-16 09:03:09 -05:00
return done ( )
}
)
} )
2021-01-04 12:04:33 -05:00
describe ( 'after unarchiving from a request for the project' , function ( ) {
beforeEach ( function ( done ) {
2020-02-16 09:03:09 -05:00
return DocstoreClient . getAllDocs (
this . project _id ,
2023-03-16 07:58:12 -04:00
( error , res , fetchedDocs ) => {
this . fetched _docs = fetchedDocs
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
return done ( )
}
)
} )
2020-05-28 09:20:54 -04:00
it ( 'should not included the deleted' , function ( done ) {
2020-02-16 09:03:09 -05:00
this . fetched _docs . length . should . equal ( 0 )
return done ( )
} )
2020-05-28 09:20:54 -04:00
return it ( 'should restore the doc to mongo' , function ( done ) {
2020-02-16 09:03:09 -05:00
return db . docs . findOne ( { _id : this . doc . _id } , ( error , doc ) => {
if ( error != null ) {
throw error
}
doc . lines . should . deep . equal ( this . doc . lines )
doc . ranges . should . deep . equal ( this . doc . ranges )
2021-03-12 17:16:01 -05:00
expect ( doc . inS3 ) . not . to . exist
2020-02-16 09:03:09 -05:00
doc . deleted . should . equal ( true )
return done ( )
} )
} )
} )
2021-01-04 12:04:33 -05:00
describe ( 'when keepSoftDeletedDocsArchived is enabled' , function ( ) {
let keepSoftDeletedDocsArchived
beforeEach ( function overwriteSetting ( ) {
keepSoftDeletedDocsArchived =
Settings . docstore . keepSoftDeletedDocsArchived
Settings . docstore . keepSoftDeletedDocsArchived = true
} )
afterEach ( function restoreSetting ( ) {
2021-07-13 07:04:48 -04:00
Settings . docstore . keepSoftDeletedDocsArchived =
keepSoftDeletedDocsArchived
2021-01-04 12:04:33 -05:00
} )
describe ( 'after unarchiving from a request for the project' , function ( ) {
beforeEach ( function ( done ) {
DocstoreClient . getAllDocs (
this . project _id ,
2023-03-16 07:58:12 -04:00
( error , res , fetchedDocs ) => {
this . fetched _docs = fetchedDocs
2021-01-04 12:04:33 -05:00
if ( error ) {
return done ( error )
}
done ( )
}
)
} )
it ( 'should not included the deleted' , function ( done ) {
this . fetched _docs . length . should . equal ( 0 )
done ( )
} )
it ( 'should not have restored the deleted doc to mongo' , function ( done ) {
db . docs . findOne ( { _id : this . doc . _id } , ( error , doc ) => {
if ( error ) {
return done ( error )
}
expect ( doc . lines ) . to . not . exist
expect ( doc . ranges ) . to . not . exist
expect ( doc . inS3 ) . to . equal ( true )
expect ( doc . deleted ) . to . equal ( true )
done ( )
} )
} )
} )
} )
2020-02-16 09:03:09 -05:00
} )
2021-01-04 06:55:47 -05:00
describe ( 'archiving a single doc' , function ( ) {
before ( function ( done ) {
2023-12-13 04:38:54 -05:00
this . project _id = new ObjectId ( )
2021-01-04 06:55:47 -05:00
this . timeout ( 1000 * 30 )
this . doc = {
2023-12-13 04:38:54 -05:00
_id : new ObjectId ( ) ,
2021-01-04 06:55:47 -05:00
lines : [ 'foo' , 'bar' ] ,
ranges : { } ,
2021-07-13 07:04:48 -04:00
version : 2 ,
2021-01-04 06:55:47 -05:00
}
DocstoreClient . createDoc (
this . project _id ,
this . doc . _id ,
this . doc . lines ,
this . doc . version ,
this . doc . ranges ,
2021-07-13 07:04:48 -04:00
error => {
2021-01-04 06:55:47 -05:00
if ( error ) {
return done ( error )
}
2022-05-17 07:49:13 -04:00
DocstoreClient . archiveDoc (
2021-01-04 06:55:47 -05:00
this . project _id ,
this . doc . _id ,
( error , res ) => {
this . res = res
if ( error ) {
return done ( error )
}
done ( )
}
)
}
)
} )
it ( 'should successully archive the doc' , function ( done ) {
this . res . statusCode . should . equal ( 204 )
done ( )
} )
it ( 'should set inS3 and unset lines and ranges in the doc' , function ( done ) {
db . docs . findOne ( { _id : this . doc . _id } , ( error , doc ) => {
if ( error ) {
return done ( error )
}
2021-03-12 17:16:01 -05:00
expect ( doc . lines ) . not . to . exist
expect ( doc . ranges ) . not . to . exist
2021-01-04 06:55:47 -05:00
doc . inS3 . should . equal ( true )
done ( )
} )
} )
it ( 'should set the doc in s3 correctly' , function ( done ) {
2023-03-16 07:58:12 -04:00
DocstoreClient . getS3Doc ( this . project _id , this . doc . _id , ( error , s3Doc ) => {
if ( error ) {
return done ( error )
2021-01-04 06:55:47 -05:00
}
2023-03-16 07:58:12 -04:00
s3Doc . lines . should . deep . equal ( this . doc . lines )
s3Doc . ranges . should . deep . equal ( this . doc . ranges )
done ( )
} )
2021-01-04 06:55:47 -05:00
} )
} )
2020-05-28 09:20:54 -04:00
describe ( 'a doc with large lines' , function ( ) {
before ( function ( done ) {
2023-12-13 04:38:54 -05:00
this . project _id = new ObjectId ( )
2020-02-16 09:03:09 -05:00
this . timeout ( 1000 * 30 )
const quarterMegInBytes = 250000
2023-03-16 07:58:12 -04:00
const bigLine = require ( 'crypto' )
2020-02-16 09:03:09 -05:00
. randomBytes ( quarterMegInBytes )
. toString ( 'hex' )
this . doc = {
2023-12-13 04:38:54 -05:00
_id : new ObjectId ( ) ,
2023-03-16 07:58:12 -04:00
lines : [ bigLine , bigLine , bigLine , bigLine ] ,
2020-02-16 09:03:09 -05:00
ranges : { } ,
2021-07-13 07:04:48 -04:00
version : 2 ,
2020-02-16 09:03:09 -05:00
}
return DocstoreClient . createDoc (
this . project _id ,
this . doc . _id ,
this . doc . lines ,
this . doc . version ,
this . doc . ranges ,
2021-07-13 07:04:48 -04:00
error => {
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
return DocstoreClient . archiveAllDoc ( this . project _id , ( error , res ) => {
this . res = res
if ( error != null ) {
throw error
}
return done ( )
} )
}
)
} )
2020-05-28 09:20:54 -04:00
it ( 'should successully archive the docs' , function ( done ) {
2020-02-16 09:03:09 -05:00
this . res . statusCode . should . equal ( 204 )
return done ( )
} )
2020-05-28 09:20:54 -04:00
it ( 'should set inS3 and unset lines and ranges in each doc' , function ( done ) {
2020-02-16 09:03:09 -05:00
return db . docs . findOne ( { _id : this . doc . _id } , ( error , doc ) => {
if ( error != null ) {
throw error
}
2021-03-12 17:16:01 -05:00
expect ( doc . lines ) . not . to . exist
expect ( doc . ranges ) . not . to . exist
2020-02-16 09:03:09 -05:00
doc . inS3 . should . equal ( true )
return done ( )
} )
} )
2020-05-28 09:20:54 -04:00
it ( 'should set the doc in s3 correctly' , function ( done ) {
2020-02-16 09:03:09 -05:00
return DocstoreClient . getS3Doc (
this . project _id ,
this . doc . _id ,
2023-03-16 07:58:12 -04:00
( error , s3Doc ) => {
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
2023-03-16 07:58:12 -04:00
s3Doc . lines . should . deep . equal ( this . doc . lines )
s3Doc . ranges . should . deep . equal ( this . doc . ranges )
2020-02-16 09:03:09 -05:00
return done ( )
}
)
} )
2020-05-28 09:20:54 -04:00
return describe ( 'after unarchiving from a request for the project' , function ( ) {
before ( function ( done ) {
2020-02-16 09:03:09 -05:00
return DocstoreClient . getAllDocs (
this . project _id ,
2023-03-16 07:58:12 -04:00
( error , res , fetchedDocs ) => {
this . fetched _docs = fetchedDocs
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
return done ( )
}
)
} )
2020-05-28 09:20:54 -04:00
return it ( 'should restore the doc to mongo' , function ( done ) {
2020-02-16 09:03:09 -05:00
return db . docs . findOne ( { _id : this . doc . _id } , ( error , doc ) => {
if ( error != null ) {
throw error
}
doc . lines . should . deep . equal ( this . doc . lines )
doc . ranges . should . deep . equal ( this . doc . ranges )
2021-03-12 17:16:01 -05:00
expect ( doc . inS3 ) . not . to . exist
2020-02-16 09:03:09 -05:00
return done ( )
} )
} )
} )
} )
2020-05-28 09:20:54 -04:00
describe ( 'a doc with naughty strings' , function ( ) {
before ( function ( done ) {
2023-12-13 04:38:54 -05:00
this . project _id = new ObjectId ( )
2020-02-16 09:03:09 -05:00
this . doc = {
2023-12-13 04:38:54 -05:00
_id : new ObjectId ( ) ,
2020-02-16 09:03:09 -05:00
lines : [
'' ,
'undefined' ,
'undef' ,
'null' ,
'NULL' ,
'(null)' ,
'nil' ,
'NIL' ,
'true' ,
'false' ,
'True' ,
'False' ,
'None' ,
'\\' ,
'\\\\' ,
'0' ,
'1' ,
'1.00' ,
'$1.00' ,
'1/2' ,
'1E2' ,
'1E02' ,
'1E+02' ,
'-1' ,
'-1.00' ,
'-$1.00' ,
'-1/2' ,
'-1E2' ,
'-1E02' ,
'-1E+02' ,
'1/0' ,
'0/0' ,
'-2147483648/-1' ,
'-9223372036854775808/-1' ,
'0.00' ,
'0..0' ,
'.' ,
'0.0.0' ,
'0,00' ,
'0,,0' ,
',' ,
'0,0,0' ,
'0.0/0' ,
'1.0/0.0' ,
'0.0/0.0' ,
'1,0/0,0' ,
'0,0/0,0' ,
'--1' ,
'-' ,
'-.' ,
'-,' ,
'999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999' ,
'NaN' ,
'Infinity' ,
'-Infinity' ,
'0x0' ,
'0xffffffff' ,
'0xffffffffffffffff' ,
'0xabad1dea' ,
'123456789012345678901234567890123456789' ,
'1,000.00' ,
'1 000.00' ,
"1'000.00" ,
'1,000,000.00' ,
'1 000 000.00' ,
"1'000'000.00" ,
'1.000,00' ,
'1 000,00' ,
"1'000,00" ,
'1.000.000,00' ,
'1 000i̳̞v̢͇ḙ͎͟-҉̭̩̼͔m̤̭̫i͕͇̝̦n̗͙ḍ̟ ̯̲͕͞ǫ̟̯̰̲͙̻̝f ̪̰̰̗̖̭̘͘c̦͍̲̞͍̩̙ḥ͚a̮͎̟̙͜ơ̩̹͎s̤.̝̝ ҉Z̡̖̜͖̰̣͉̜a͖̰͙̬͡l̲̫̳͍̩g̡̟̼̱͚̞̬ͅo̗͜.̟' ,
'̦H̬̤̗̤͝e͜ ̜̥̝̻͍̟́w̕h̖̯͓o̝͙̖͎̱̮ ҉̺̙̞̟͈W̷̼̭a̺̪͍į͈͕̭͙̯̜t̶̼̮s̘͙͖̕ ̠̫̠B̻͍͙͉̳ͅe̵h̵̬͇̫͙i̹͓̳̳̮͎̫̕n͟d̴̪̜̖ ̰͉̩͇͙̲͞ͅT͖̼͓̪͢h͏ ͓̮̻e̬̝̟ͅ ̤̹̝W͙̞̝͔͇͝ͅa͏ ͓͔̹̼̣l̴͔̰̤̟͔ḽ̫.͕' ,
'Z̮̞̠͙͔ͅḀ̗̞͈̻̗Ḷ͙͎̯̹̞͓G̻O̭̗̮' ,
"˙ɐnbᴉlɐ ɐuƃɐɯ ǝɹolop ʇǝ ǝɹoqɐl ʇn ʇunpᴉpᴉɔuᴉ ɹodɯ ǝʇ poɯ snᴉǝ op pǝs 'ʇᴉlǝ ƃuᴉɔsᴉdᴉpɐ ɹnʇǝʇɔǝsuoɔ 'ʇǝɯɐ ʇᴉs ɹolop ɯ nsdᴉ ɯ ǝɹo˥" ,
'00˙Ɩ$-' ,
'T h e q u i c k b r o w n f o x j u m p s o v e r t h e l a z y d o g ' ,
'𝐓 𝐡 𝐞 𝐪 𝐮 𝐢 𝐜 𝐤 𝐛 𝐫 𝐨 𝐰 𝐧 𝐟 𝐨 𝐱 𝐣𝐮𝐦𝐩𝐬 𝐨 𝐯 𝐞 𝐫 𝐭 𝐡 𝐞 𝐥 𝐚 𝐳 𝐲 𝐝 𝐨 𝐠 ' ,
'𝕿 𝖍 𝖊 𝖖 𝖚 𝖎 𝖈 𝖐 𝖇 𝖗 𝖔 𝖜 𝖓 𝖋 𝖔 𝖝 𝖏𝖚𝖒𝖕𝖘 𝖔 𝖛 𝖊 𝖗 𝖙 𝖍 𝖊 𝖑 𝖆 𝖟 𝖞 𝖉 𝖔 𝖌 ' ,
'𝑻 𝒉 𝒆 𝒒 𝒖 𝒊 𝒄 𝒌 𝒃 𝒓 𝒐 𝒘 𝒏 𝒇 𝒐 𝒙 𝒋𝒖𝒎𝒑𝒔 𝒐 𝒗 𝒆 𝒓 𝒕 𝒉 𝒆 𝒍 𝒂 𝒛 𝒚 𝒅 𝒐 𝒈 ' ,
'𝓣 𝓱 𝓮 𝓺 𝓾 𝓲 𝓬 𝓴 𝓫 𝓻 𝓸 𝔀 𝓷 𝓯 𝓸 𝔁 𝓳𝓾𝓶𝓹𝓼 𝓸 𝓿 𝓮 𝓻 𝓽 𝓱 𝓮 𝓵 𝓪 𝔃 𝔂 𝓭 𝓸 𝓰 ' ,
'𝕋 𝕙 𝕖 𝕢 𝕦 𝕚 𝕔 𝕜 𝕓 𝕣 𝕠 𝕨 𝕟 𝕗 𝕠 𝕩 𝕛𝕦𝕞𝕡𝕤 𝕠 𝕧 𝕖 𝕣 𝕥 𝕙 𝕖 𝕝 𝕒 𝕫 𝕪 𝕕 𝕠 𝕘 ' ,
'𝚃 𝚑 𝚎 𝚚 𝚞 𝚒 𝚌 𝚔 𝚋 𝚛 𝚘 𝚠 𝚗 𝚏 𝚘 𝚡 𝚓𝚞𝚖𝚙𝚜 𝚘 𝚟 𝚎 𝚛 𝚝 𝚑 𝚎 𝚕 𝚊 𝚣 𝚢 𝚍 𝚘 𝚐 ' ,
'⒯⒣⒠ ⒬⒰⒤⒞⒦ ⒝⒭⒪⒲⒩ ⒡⒪⒳ ⒥⒰⒨⒫⒮ ⒪⒱⒠⒭ ⒯⒣⒠ ⒧⒜⒵⒴ ⒟⒪⒢' ,
'<script>alert(123)</script>' ,
'<script>alert('123');</script>' ,
'<img src=x onerror=alert(123) />' ,
'<svg><script>123<1>alert(123)</script> ' ,
'"><script>alert(123)</script>' ,
"'><script>alert(123)</script>" ,
'><script>alert(123)</script>' ,
'</script><script>alert(123)</script>' ,
'< / script >< script >alert(123)< / script >' ,
' onfocus=JaVaSCript:alert(123) autofocus ' ,
'" onfocus=JaVaSCript:alert(123) autofocus ' ,
"' onfocus=JaVaSCript:alert(123) autofocus " ,
'< script> alert(123)< /script> ' ,
'<sc<script>ript>alert(123)</sc</script>ript>' ,
'--><script>alert(123)</script>' ,
'";alert(123);t="' ,
"';alert(123);t='" ,
'JavaSCript:alert(123)' ,
';alert(123);' ,
'src=JaVaSCript:prompt(132)' ,
'"><script>alert(123);</script x="' ,
"'><script>alert(123);</script x='" ,
'><script>alert(123);</script x=' ,
'" autofocus onkeyup="javascript:alert(123)' ,
"' autofocus onkeyup='javascript:alert(123)" ,
'<script\\x20type="text/javascript">javascript:alert(1);</script>' ,
'<script\\x3Etype="text/javascript">javascript:alert(1);</script>' ,
'<script\\x0Dtype="text/javascript">javascript:alert(1);</script>' ,
'<script\\x09type="text/javascript">javascript:alert(1);</script>' ,
'<script\\x0Ctype="text/javascript">javascript:alert(1);</script>' ,
'<script\\x2Ftype="text/javascript">javascript:alert(1);</script>' ,
'<script\\x0Atype="text/javascript">javascript:alert(1);</script>' ,
'\'`"><\\x3Cscript>javascript:alert(1)</script> ' ,
'\'`"><\\x00script>javascript:alert(1)</script>' ,
'ABC<div style="x\\x3Aexpression(javascript:alert(1)">DEF' ,
'ABC<div style="x:expression\\x5C(javascript:alert(1)">DEF' ,
'ABC<div style="x:expression\\x00(javascript:alert(1)">DEF' ,
'ABC<div style="x:exp\\x00ression(javascript:alert(1)">DEF' ,
'ABC<div style="x:exp\\x5Cression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\x0Aexpression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\x09expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xE3\\x80\\x80expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xE2\\x80\\x84expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xC2\\xA0expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xE2\\x80\\x80expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xE2\\x80\\x8Aexpression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\x0Dexpression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\x0Cexpression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xE2\\x80\\x87expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xEF\\xBB\\xBFexpression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\x20expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xE2\\x80\\x88expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\x00expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xE2\\x80\\x8Bexpression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xE2\\x80\\x86expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xE2\\x80\\x85expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xE2\\x80\\x82expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\x0Bexpression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xE2\\x80\\x81expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xE2\\x80\\x83expression(javascript:alert(1)">DEF' ,
'ABC<div style="x:\\xE2\\x80\\x89expression(javascript:alert(1)">DEF' ,
'<a href="\\x0Bjavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x0Fjavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xC2\\xA0javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x05javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE1\\xA0\\x8Ejavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x18javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x11javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\x88javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\x89javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\x80javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x17javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x03javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x0Ejavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x1Ajavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x00javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x10javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\x82javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x20javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x13javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x09javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\x8Ajavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x14javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x19javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\xAFjavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x1Fjavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\x81javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x1Djavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\x87javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x07javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE1\\x9A\\x80javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\x83javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x04javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x01javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x08javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\x84javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\x86javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE3\\x80\\x80javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x12javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x0Djavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x0Ajavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x0Cjavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x15javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\xA8javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x16javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x02javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x1Bjavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x06javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\xA9javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x80\\x85javascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x1Ejavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\xE2\\x81\\x9Fjavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="\\x1Cjavascript:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="javascript\\x00:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="javascript\\x3A:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="javascript\\x09:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="javascript\\x0D:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'<a href="javascript\\x0A:javascript:alert(1)" id="fuzzelement1">test</a>' ,
'`"\'><img src=xxx:x \\x0Aonerror=javascript:alert(1)>' ,
'`"\'><img src=xxx:x \\x22onerror=javascript:alert(1)>' ,
'`"\'><img src=xxx:x \\x0Bonerror=javascript:alert(1)>' ,
'`"\'><img src=xxx:x \\x0Donerror=javascript:alert(1)>' ,
'`"\'><img src=xxx:x \\x2Fonerror=javascript:alert(1)>' ,
'`"\'><img src=xxx:x \\x09onerror=javascript:alert(1)>' ,
'`"\'><img src=xxx:x \\x0Conerror=javascript:alert(1)>' ,
'`"\'><img src=xxx:x \\x00onerror=javascript:alert(1)>' ,
'`"\'><img src=xxx:x \\x27onerror=javascript:alert(1)>' ,
'`"\'><img src=xxx:x \\x20onerror=javascript:alert(1)>' ,
'"`\'><script>\\x3Bjavascript:alert(1)</script>' ,
'"`\'><script>\\x0Djavascript:alert(1)</script>' ,
'"`\'><script>\\xEF\\xBB\\xBFjavascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\x81javascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\x84javascript:alert(1)</script>' ,
'"`\'><script>\\xE3\\x80\\x80javascript:alert(1)</script>' ,
'"`\'><script>\\x09javascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\x89javascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\x85javascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\x88javascript:alert(1)</script>' ,
'"`\'><script>\\x00javascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\xA8javascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\x8Ajavascript:alert(1)</script>' ,
'"`\'><script>\\xE1\\x9A\\x80javascript:alert(1)</script>' ,
'"`\'><script>\\x0Cjavascript:alert(1)</script>' ,
'"`\'><script>\\x2Bjavascript:alert(1)</script>' ,
'"`\'><script>\\xF0\\x90\\x96\\x9Ajavascript:alert(1)</script>' ,
'"`\'><script>-javascript:alert(1)</script>' ,
'"`\'><script>\\x0Ajavascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\xAFjavascript:alert(1)</script>' ,
'"`\'><script>\\x7Ejavascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\x87javascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x81\\x9Fjavascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\xA9javascript:alert(1)</script>' ,
'"`\'><script>\\xC2\\x85javascript:alert(1)</script>' ,
'"`\'><script>\\xEF\\xBF\\xAEjavascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\x83javascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\x8Bjavascript:alert(1)</script>' ,
'"`\'><script>\\xEF\\xBF\\xBEjavascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\x80javascript:alert(1)</script>' ,
'"`\'><script>\\x21javascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\x82javascript:alert(1)</script>' ,
'"`\'><script>\\xE2\\x80\\x86javascript:alert(1)</script>' ,
'"`\'><script>\\xE1\\xA0\\x8Ejavascript:alert(1)</script>' ,
'"`\'><script>\\x0Bjavascript:alert(1)</script>' ,
'"`\'><script>\\x20javascript:alert(1)</script>' ,
'"`\'><script>\\xC2\\xA0javascript:alert(1)</script>' ,
'<img \\x00src=x onerror="alert(1)">' ,
'<img \\x47src=x onerror="javascript:alert(1)">' ,
'<img \\x11src=x onerror="javascript:alert(1)">' ,
'<img \\x12src=x onerror="javascript:alert(1)">' ,
'<img\\x47src=x onerror="javascript:alert(1)">' ,
'<img\\x10src=x onerror="javascript:alert(1)">' ,
'<img\\x13src=x onerror="javascript:alert(1)">' ,
'<img\\x32src=x onerror="javascript:alert(1)">' ,
'<img\\x47src=x onerror="javascript:alert(1)">' ,
'<img\\x11src=x onerror="javascript:alert(1)">' ,
'<img \\x47src=x onerror="javascript:alert(1)">' ,
'<img \\x34src=x onerror="javascript:alert(1)">' ,
'<img \\x39src=x onerror="javascript:alert(1)">' ,
'<img \\x00src=x onerror="javascript:alert(1)">' ,
'<img src\\x09=x onerror="javascript:alert(1)">' ,
'<img src\\x10=x onerror="javascript:alert(1)">' ,
'<img src\\x13=x onerror="javascript:alert(1)">' ,
'<img src\\x32=x onerror="javascript:alert(1)">' ,
'<img src\\x12=x onerror="javascript:alert(1)">' ,
'<img src\\x11=x onerror="javascript:alert(1)">' ,
'<img src\\x00=x onerror="javascript:alert(1)">' ,
'<img src\\x47=x onerror="javascript:alert(1)">' ,
'<img src=x\\x09onerror="javascript:alert(1)">' ,
'<img src=x\\x10onerror="javascript:alert(1)">' ,
'<img src=x\\x11onerror="javascript:alert(1)">' ,
'<img src=x\\x12onerror="javascript:alert(1)">' ,
'<img src=x\\x13onerror="javascript:alert(1)">' ,
'<img[a][b][c]src[d]=x[e]onerror=[f]"alert(1)">' ,
'<img src=x onerror=\\x09"javascript:alert(1)">' ,
'<img src=x onerror=\\x10"javascript:alert(1)">' ,
'<img src=x onerror=\\x11"javascript:alert(1)">' ,
'<img src=x onerror=\\x12"javascript:alert(1)">' ,
'<img src=x onerror=\\x32"javascript:alert(1)">' ,
'<img src=x onerror=\\x00"javascript:alert(1)">' ,
'<a href=javascript:javascript:alert(1)>XXX</a>' ,
'<img src="x` `<script>javascript:alert(1)</script>"` `>' ,
'<img src onerror /" \'"= alt=javascript:alert(1)//">' ,
'<title onpropertychange=javascript:alert(1)></title><title title=>' ,
'<a href=http://foo.bar/#x=`y></a><img alt="`><img src=x:x onerror=javascript:alert(1)></a>">' ,
'<!--[if]><script>javascript:alert(1)</script -->' ,
'<!--[if<img src=x onerror=javascript:alert(1)//]> -->' ,
'<script src="/\\%(jscript)s"></script>' ,
'<script src="\\\\%(jscript)s"></script>' ,
'<IMG """><SCRIPT>alert("XSS")</SCRIPT>">' ,
'<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>' ,
'<IMG SRC=# onmouseover="alert(\'xxs\')">' ,
'<IMG SRC= onmouseover="alert(\'xxs\')">' ,
'<IMG onmouseover="alert(\'xxs\')">' ,
'<IMG SRC=javascript:alert('XSS')>' ,
'<IMG SRC=javascript:alert('XSS')>' ,
'<IMG SRC=javascript:alert('XSS')>' ,
'<IMG SRC="jav ascript:alert(\'XSS\');">' ,
'<IMG SRC="jav	ascript:alert(\'XSS\');">' ,
'<IMG SRC="jav
ascript:alert(\'XSS\');">' ,
'<IMG SRC="jav
ascript:alert(\'XSS\');">' ,
'perl -e \'print "<IMG SRC=java\\0script:alert(\\"XSS\\")>";\' > out' ,
'<IMG SRC="  javascript:alert(\'XSS\');">' ,
'<SCRIPT/XSS SRC="http://ha.ckers.org/xss.js"></SCRIPT>' ,
'<BODY onload!#$%&()*~+-_.,:;?@[/|\\]^`=alert("XSS")>' ,
'<SCRIPT/SRC="http://ha.ckers.org/xss.js"></SCRIPT>' ,
'<<SCRIPT>alert("XSS");//<</SCRIPT>' ,
'<SCRIPT SRC=http://ha.ckers.org/xss.js?< B >' ,
'<SCRIPT SRC=//ha.ckers.org/.j>' ,
'<IMG SRC="javascript:alert(\'XSS\')"' ,
'<iframe src=http://ha.ckers.org/scriptlet.html <' ,
"\\\";alert('XSS');//" ,
'<plaintext>' ,
'1;DROP TABLE users' ,
"1'; DROP TABLE users-- 1" ,
"' OR 1=1 -- 1" ,
"' OR '1'='1" ,
'-' ,
'--' ,
'--version' ,
'--help' ,
'$USER' ,
'/dev/null; touch /tmp/blns.fail ; echo' ,
'`touch /tmp/blns.fail`' ,
'$(touch /tmp/blns.fail)' ,
'@{[system "touch /tmp/blns.fail"]}' ,
'eval("puts \'hello world\'")' ,
'System("ls -al /")' ,
'`ls -al /`' ,
'Kernel.exec("ls -al /")' ,
'Kernel.exit(1)' ,
"%x('ls -al /')" ,
'<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE foo [ <!ELEMENT foo ANY ><!ENTITY xxe SYSTEM "file:///etc/passwd" >]><foo>&xxe;</foo>' ,
'$HOME' ,
"$ENV{'HOME'}" ,
'%d' ,
'%s' ,
'%*.*s' ,
'../../../../../../../../../../../etc/passwd%00' ,
'../../../../../../../../../../../etc/hosts' ,
'() { 0; }; touch /tmp/blns.shellshock1.fail;' ,
'() { _; } >_[$($())] { touch /tmp/blns.shellshock2.fail; }' ,
'CON' ,
'PRN' ,
'AUX' ,
'CLOCK$' ,
'NUL' ,
'A:' ,
'ZZ:' ,
'COM1' ,
'LPT1' ,
'LPT2' ,
'LPT3' ,
'COM2' ,
'COM3' ,
'COM4' ,
'Scunthorpe General Hospital' ,
'Penistone Community Church' ,
'Lightwater Country Park' ,
'Jimmy Clitheroe' ,
'Horniman Museum' ,
'shitake mushrooms' ,
'RomansInSussex.co.uk' ,
'http://www.cum.qc.ca/' ,
'Craig Cockburn, Software Specialist' ,
'Linda Callahan' ,
'Dr. Herman I. Libshitz' ,
'magna cum laude' ,
'Super Bowl XXX' ,
'medieval erection of parapets' ,
'evaluate' ,
'mocha' ,
'expression' ,
'Arsenal canal' ,
'classic' ,
'Tyson Gay' ,
"If you're reading this, you've been in a coma for almost 20 years now. We're trying a new technique. We don't know where this message will end up in your dream, but we hope it works. Please wake up, we miss you." ,
'Roses are \u001b[0;31mred\u001b[0m, violets are \u001b[0;34mblue. Hope you enjoy terminal hue' ,
'But now...\u001b[20Cfor my greatest trick...\u001b[8m' ,
'The quic\b\b\b\b\b\bk brown fo\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007x... [Beeeep]' ,
2021-07-13 07:04:48 -04:00
'Powerلُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ冗' ,
2020-02-16 09:03:09 -05:00
] ,
ranges : { } ,
2021-07-13 07:04:48 -04:00
version : 2 ,
2020-02-16 09:03:09 -05:00
}
return DocstoreClient . createDoc (
this . project _id ,
this . doc . _id ,
this . doc . lines ,
this . doc . version ,
this . doc . ranges ,
2021-07-13 07:04:48 -04:00
error => {
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
return DocstoreClient . archiveAllDoc ( this . project _id , ( error , res ) => {
this . res = res
if ( error != null ) {
throw error
}
return done ( )
} )
}
)
} )
2020-05-28 09:20:54 -04:00
it ( 'should successully archive the docs' , function ( done ) {
2020-02-16 09:03:09 -05:00
this . res . statusCode . should . equal ( 204 )
return done ( )
} )
2020-05-28 09:20:54 -04:00
it ( 'should set inS3 and unset lines and ranges in each doc' , function ( done ) {
2020-02-16 09:03:09 -05:00
return db . docs . findOne ( { _id : this . doc . _id } , ( error , doc ) => {
if ( error != null ) {
throw error
}
2021-03-12 17:16:01 -05:00
expect ( doc . lines ) . not . to . exist
expect ( doc . ranges ) . not . to . exist
2020-02-16 09:03:09 -05:00
doc . inS3 . should . equal ( true )
return done ( )
} )
} )
2020-05-28 09:20:54 -04:00
it ( 'should set the doc in s3 correctly' , function ( done ) {
2020-02-16 09:03:09 -05:00
return DocstoreClient . getS3Doc (
this . project _id ,
this . doc . _id ,
2023-03-16 07:58:12 -04:00
( error , s3Doc ) => {
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
2023-03-16 07:58:12 -04:00
s3Doc . lines . should . deep . equal ( this . doc . lines )
s3Doc . ranges . should . deep . equal ( this . doc . ranges )
2020-02-16 09:03:09 -05:00
return done ( )
}
)
} )
2020-05-28 09:20:54 -04:00
return describe ( 'after unarchiving from a request for the project' , function ( ) {
before ( function ( done ) {
2020-02-16 09:03:09 -05:00
return DocstoreClient . getAllDocs (
this . project _id ,
2023-03-16 07:58:12 -04:00
( error , res , fetchedDocs ) => {
this . fetched _docs = fetchedDocs
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
return done ( )
}
)
} )
2020-05-28 09:20:54 -04:00
return it ( 'should restore the doc to mongo' , function ( done ) {
2020-02-16 09:03:09 -05:00
return db . docs . findOne ( { _id : this . doc . _id } , ( error , doc ) => {
if ( error != null ) {
throw error
}
doc . lines . should . deep . equal ( this . doc . lines )
doc . ranges . should . deep . equal ( this . doc . ranges )
2021-03-12 17:16:01 -05:00
expect ( doc . inS3 ) . not . to . exist
2020-02-16 09:03:09 -05:00
return done ( )
} )
} )
} )
} )
2020-05-28 09:20:54 -04:00
describe ( 'a doc with ranges' , function ( ) {
before ( function ( done ) {
2023-12-13 04:38:54 -05:00
this . project _id = new ObjectId ( )
2020-02-16 09:03:09 -05:00
this . doc = {
2023-12-13 04:38:54 -05:00
_id : new ObjectId ( ) ,
2020-02-16 09:03:09 -05:00
lines : [ 'one' , 'two' , 'three' ] ,
ranges : {
changes : [
{
2023-12-13 04:38:54 -05:00
id : new ObjectId ( ) ,
2020-02-16 09:03:09 -05:00
op : { i : 'foo' , p : 24 } ,
metadata : {
2023-12-13 04:38:54 -05:00
user _id : new ObjectId ( ) ,
2021-07-13 07:04:48 -04:00
ts : new Date ( '2017-01-27T16:10:44.194Z' ) ,
} ,
2020-02-16 09:03:09 -05:00
} ,
{
2023-12-13 04:38:54 -05:00
id : new ObjectId ( ) ,
2020-02-16 09:03:09 -05:00
op : { d : 'bar' , p : 50 } ,
metadata : {
2023-12-13 04:38:54 -05:00
user _id : new ObjectId ( ) ,
2021-07-13 07:04:48 -04:00
ts : new Date ( '2017-01-27T18:10:44.194Z' ) ,
} ,
} ,
2020-02-16 09:03:09 -05:00
] ,
comments : [
{
2023-12-13 04:38:54 -05:00
id : new ObjectId ( ) ,
op : { c : 'comment' , p : 284 , t : new ObjectId ( ) } ,
2020-02-16 09:03:09 -05:00
metadata : {
2023-12-13 04:38:54 -05:00
user _id : new ObjectId ( ) ,
2021-07-13 07:04:48 -04:00
ts : new Date ( '2017-01-26T14:22:04.869Z' ) ,
} ,
} ,
] ,
2020-02-16 09:03:09 -05:00
} ,
2021-07-13 07:04:48 -04:00
version : 2 ,
2020-02-16 09:03:09 -05:00
}
return DocstoreClient . createDoc (
this . project _id ,
this . doc . _id ,
this . doc . lines ,
this . doc . version ,
this . doc . ranges ,
2021-07-13 07:04:48 -04:00
error => {
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
return DocstoreClient . archiveAllDoc ( this . project _id , ( error , res ) => {
this . res = res
if ( error != null ) {
throw error
}
return done ( )
} )
}
)
} )
2020-05-28 09:20:54 -04:00
it ( 'should successully archive the docs' , function ( done ) {
2020-02-16 09:03:09 -05:00
this . res . statusCode . should . equal ( 204 )
return done ( )
} )
2020-05-28 09:20:54 -04:00
it ( 'should set inS3 and unset lines and ranges in each doc' , function ( done ) {
2020-02-16 09:03:09 -05:00
return db . docs . findOne ( { _id : this . doc . _id } , ( error , doc ) => {
if ( error != null ) {
throw error
}
2021-03-12 17:16:01 -05:00
expect ( doc . lines ) . not . to . exist
expect ( doc . ranges ) . not . to . exist
2020-02-16 09:03:09 -05:00
doc . inS3 . should . equal ( true )
return done ( )
} )
} )
2020-05-28 09:20:54 -04:00
it ( 'should set the doc in s3 correctly' , function ( done ) {
2020-02-16 09:03:09 -05:00
return DocstoreClient . getS3Doc (
this . project _id ,
this . doc . _id ,
2023-03-16 07:58:12 -04:00
( error , s3Doc ) => {
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
2023-03-16 07:58:12 -04:00
s3Doc . lines . should . deep . equal ( this . doc . lines )
2020-02-16 09:03:09 -05:00
const ranges = JSON . parse ( JSON . stringify ( this . doc . ranges ) ) // ObjectId -> String
2023-03-16 07:58:12 -04:00
s3Doc . ranges . should . deep . equal ( ranges )
2020-02-16 09:03:09 -05:00
return done ( )
}
)
} )
2020-05-28 09:20:54 -04:00
return describe ( 'after unarchiving from a request for the project' , function ( ) {
before ( function ( done ) {
2020-02-16 09:03:09 -05:00
return DocstoreClient . getAllDocs (
this . project _id ,
2023-03-16 07:58:12 -04:00
( error , res , fetchedDocs ) => {
this . fetched _docs = fetchedDocs
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
return done ( )
}
)
} )
2020-05-28 09:20:54 -04:00
return it ( 'should restore the doc to mongo' , function ( done ) {
2020-02-16 09:03:09 -05:00
return db . docs . findOne ( { _id : this . doc . _id } , ( error , doc ) => {
if ( error != null ) {
throw error
}
doc . lines . should . deep . equal ( this . doc . lines )
doc . ranges . should . deep . equal ( this . doc . ranges )
2021-03-12 17:16:01 -05:00
expect ( doc . inS3 ) . not . to . exist
2020-02-16 09:03:09 -05:00
return done ( )
} )
} )
} )
} )
2020-05-28 09:20:54 -04:00
describe ( 'a doc that is archived twice' , function ( ) {
before ( function ( done ) {
2023-12-13 04:38:54 -05:00
this . project _id = new ObjectId ( )
2020-02-16 09:03:09 -05:00
this . doc = {
2023-12-13 04:38:54 -05:00
_id : new ObjectId ( ) ,
2020-02-16 09:03:09 -05:00
lines : [ 'abc' , 'def' , 'ghi' ] ,
ranges : { } ,
2021-07-13 07:04:48 -04:00
version : 2 ,
2020-02-16 09:03:09 -05:00
}
return DocstoreClient . createDoc (
this . project _id ,
this . doc . _id ,
this . doc . lines ,
this . doc . version ,
this . doc . ranges ,
2021-07-13 07:04:48 -04:00
error => {
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
return DocstoreClient . archiveAllDoc ( this . project _id , ( error , res ) => {
this . res = res
if ( error != null ) {
throw error
}
this . res . statusCode . should . equal ( 204 )
return DocstoreClient . archiveAllDoc (
this . project _id ,
( error , res1 ) => {
this . res = res1
if ( error != null ) {
throw error
}
this . res . statusCode . should . equal ( 204 )
return done ( )
}
)
} )
}
)
} )
2020-05-28 09:20:54 -04:00
it ( 'should set inS3 and unset lines and ranges in each doc' , function ( done ) {
2020-02-16 09:03:09 -05:00
return db . docs . findOne ( { _id : this . doc . _id } , ( error , doc ) => {
if ( error != null ) {
throw error
}
2021-03-12 17:16:01 -05:00
expect ( doc . lines ) . not . to . exist
expect ( doc . ranges ) . not . to . exist
2020-02-16 09:03:09 -05:00
doc . inS3 . should . equal ( true )
return done ( )
} )
} )
2020-05-28 09:20:54 -04:00
it ( 'should set the doc in s3 correctly' , function ( done ) {
2020-02-16 09:03:09 -05:00
return DocstoreClient . getS3Doc (
this . project _id ,
this . doc . _id ,
2023-03-16 07:58:12 -04:00
( error , s3Doc ) => {
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
2023-03-16 07:58:12 -04:00
s3Doc . lines . should . deep . equal ( this . doc . lines )
s3Doc . ranges . should . deep . equal ( this . doc . ranges )
2020-02-16 09:03:09 -05:00
return done ( )
}
)
} )
2020-05-28 09:20:54 -04:00
return describe ( 'after unarchiving from a request for the project' , function ( ) {
before ( function ( done ) {
2020-02-16 09:03:09 -05:00
return DocstoreClient . getAllDocs (
this . project _id ,
2023-03-16 07:58:12 -04:00
( error , res , fetchedDocs ) => {
this . fetched _docs = fetchedDocs
2020-02-16 09:03:09 -05:00
if ( error != null ) {
throw error
}
return done ( )
}
)
} )
2020-05-28 09:20:54 -04:00
return it ( 'should restore the doc to mongo' , function ( done ) {
2020-02-16 09:03:09 -05:00
return db . docs . findOne ( { _id : this . doc . _id } , ( error , doc ) => {
if ( error != null ) {
throw error
}
doc . lines . should . deep . equal ( this . doc . lines )
doc . ranges . should . deep . equal ( this . doc . ranges )
2021-03-12 17:16:01 -05:00
expect ( doc . inS3 ) . not . to . exist
2020-02-16 09:03:09 -05:00
return done ( )
} )
} )
} )
} )
2020-05-28 09:20:54 -04:00
return describe ( 'a doc with the old schema (just an array of lines)' , function ( ) {
before ( function ( done ) {
2023-12-13 04:38:54 -05:00
this . project _id = new ObjectId ( )
2020-02-16 09:03:09 -05:00
this . doc = {
2023-12-13 04:38:54 -05:00
_id : new ObjectId ( ) ,
2020-02-16 09:03:09 -05:00
lines : [ 'abc' , 'def' , 'ghi' ] ,
ranges : { } ,
2021-07-13 07:04:48 -04:00
version : 2 ,
2020-02-16 09:03:09 -05:00
}
2020-07-23 14:43:33 -04:00
uploadContent (
` ${ this . project _id } / ${ this . doc . _id } ` ,
this . doc . lines ,
2021-07-13 07:04:48 -04:00
error => {
2020-07-23 14:43:33 -04:00
expect ( error ) . not . to . exist
2023-12-13 04:38:54 -05:00
db . docs . insertOne (
2020-07-23 14:43:33 -04:00
{
project _id : this . project _id ,
_id : this . doc . _id ,
rev : this . doc . version ,
2021-07-13 07:04:48 -04:00
inS3 : true ,
2020-07-23 14:43:33 -04:00
} ,
2021-07-13 07:04:48 -04:00
error => {
2020-07-23 14:43:33 -04:00
if ( error != null ) {
throw error
2020-02-16 09:03:09 -05:00
}
2020-07-23 14:43:33 -04:00
DocstoreClient . getAllDocs (
this . project _id ,
2023-03-16 07:58:12 -04:00
( error , res , fetchedDocs ) => {
this . fetched _docs = fetchedDocs
2020-07-23 14:43:33 -04:00
if ( error != null ) {
throw error
}
return done ( )
}
)
}
)
}
)
2020-02-16 09:03:09 -05:00
} )
2020-05-28 09:20:54 -04:00
it ( 'should restore the doc to mongo' , function ( done ) {
2020-02-16 09:03:09 -05:00
return db . docs . findOne ( { _id : this . doc . _id } , ( error , doc ) => {
if ( error != null ) {
throw error
}
doc . lines . should . deep . equal ( this . doc . lines )
2021-03-12 17:16:01 -05:00
expect ( doc . inS3 ) . not . to . exist
2020-02-16 09:03:09 -05:00
return done ( )
} )
} )
2020-05-28 09:20:54 -04:00
return it ( 'should return the doc' , function ( done ) {
2020-02-16 09:03:09 -05:00
this . fetched _docs [ 0 ] . lines . should . deep . equal ( this . doc . lines )
return done ( )
} )
} )
} )