コード例 #1
0
ファイル: RsaTest.js プロジェクト: tutao/tutanota
	o("hex key conversion", function () {
		let keyPair = _getKeyPair()
		let hexPrivateKey = privateKeyToHex(keyPair.privateKey)
		let hexPublicKey = publicKeyToHex(keyPair.publicKey)
		o(privateKeyToHex(hexToPrivateKey(hexPrivateKey))).equals(hexPrivateKey)
		o(publicKeyToHex(hexToPublicKey(hexPublicKey))).equals(hexPublicKey)
	})
コード例 #2
0
ファイル: AesTest.js プロジェクト: tutao/tutanota
	function ciphertextLengths(key, encrypt, length15BytePlainText, length16BytePlainText, useMac) {
		// check that 15 bytes fit into one block
		o(encrypt(key, stringToUtf8Uint8Array("1234567890abcde"), random.generateRandomData(IV_BYTE_LENGTH), true, useMac).length).equals(length15BytePlainText)
		// check that 16 bytes need two blocks (because of one byte padding length info)
		o(encrypt(key, stringToUtf8Uint8Array("1234567890abcdef"), random.generateRandomData(IV_BYTE_LENGTH), true, useMac).length)
			.equals(length16BytePlainText)
	}
コード例 #3
0
ファイル: RsaTest.js プロジェクト: tutao/tutanota
	o("test randomizer adapter", function (done) {
		let a = []
		a.length = 100

		let seed = new Uint8Array(a.length)
		crypto.getRandomValues(seed)

		random.generateRandomData = (number) => seed

		let secureRandom = new SecureRandom();
		secureRandom.nextBytes(a)
		o(a).deepEquals(Array.from(seed))

		random.generateRandomData = (number) => {
			throw new CryptoError("test randomizer adapter")
		}

		try {
			secureRandom.nextBytes([0])
		} catch (e) {
			o(e.message).equals("test randomizer adapter")
			o(e instanceof CryptoError).equals(true)
			done()
		}
	})
コード例 #4
0
ファイル: AesTest.js プロジェクト: tutao/tutanota
	function decryptInvalidData(done, key, decrypt, errorMessage) {
		try {
			(decrypt: any)(key, new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]), true, false) // useMac is only used for aes256Decrypt
		} catch (e) {
			o(e instanceof CryptoError).equals(true)
			o(e.message).equals(errorMessage)
			done()
		}
	}
コード例 #5
0
ファイル: AesTest.js プロジェクト: tutao/tutanota
	function decryptWithWrongKey(done, key, key2, encrypt, decrypt, useMac, errorMessage) {
		try {
			let encrypted = encrypt(key, stringToUtf8Uint8Array("hello"), random.generateRandomData(IV_BYTE_LENGTH), true, useMac);
			(decrypt: any)(key2, encrypted, true, useMac) // useMac is only used for aes256Decrypt
		} catch (e) {
			o(e instanceof CryptoError).equals(true)
			o(e.message).equals(errorMessage)
			done()
		}
	}
コード例 #6
0
ファイル: AesTest.js プロジェクト: tutao/tutanota
	// o("encryptWithInvalidKey 256 webcrypto", done => encryptWithInvalidKey(done, aes256EncryptFile, true))
	function encryptWithInvalidKey(done, encrypt, useMac) {
		let key = _hexToKey("7878787878")
		try {
			encrypt(key, stringToUtf8Uint8Array("hello"), random.generateRandomData(IV_BYTE_LENGTH), true, useMac)
		} catch (e) {
			o(e instanceof CryptoError).equals(true)
			o(e.message.startsWith("Illegal key length")).equals(true)
			done()
		}
	}
コード例 #7
0
ファイル: AesTest.js プロジェクト: tutao/tutanota
	// o("decryptWithInvalidKey 256 webcrypto", done => decryptWithInvalidKey(done, aes256DecryptFile))
	function decryptWithInvalidKey(done, decrypt) {
		let key = _hexToKey("7878787878")
		try {
			(decrypt: any)(key, stringToUtf8Uint8Array("hello"), true, false) // useMac is only used for aes256Decrypt
		} catch (e) {
			o(e instanceof CryptoError).equals(true)
			o(e.message.startsWith("Illegal key length")).equals(true)
			done()
		}
	}
コード例 #8
0
ファイル: RsaTest.js プロジェクト: tutao/tutanota
	o("_mgf1 ", function () {
		let bytes = new Uint8Array([1, 2, 3, 4])
		o(uint8ArrayToHex(mgf1(bytes, 32))).equals("e25f9f0a2c2664632d1be5e2f25b2794c371091b61eb762ad98861da3a2221ee")
		o(uint8ArrayToHex(mgf1(bytes, 63)))
			.equals("e25f9f0a2c2664632d1be5e2f25b2794c371091b61eb762ad98861da3a2221ee366dcb38806a930d052d8b7bac72a4e59bbe8a78792b4d975ed944dc0f64f6")
		o(uint8ArrayToHex(mgf1(bytes, 64)))
			.equals("e25f9f0a2c2664632d1be5e2f25b2794c371091b61eb762ad98861da3a2221ee366dcb38806a930d052d8b7bac72a4e59bbe8a78792b4d975ed944dc0f64f6e5")
		o(uint8ArrayToHex(mgf1(bytes, 65)))
			.equals("e25f9f0a2c2664632d1be5e2f25b2794c371091b61eb762ad98861da3a2221ee366dcb38806a930d052d8b7bac72a4e59bbe8a78792b4d975ed944dc0f64f6e5c3")
	})
コード例 #9
0
ファイル: U2fClientTest.js プロジェクト: Ch4p34uN0iR/tutanota
	o("testDecodeRegisterResponse", function () {
		let u2f = new U2fClient();
		// test data can be extracted from the yubico java impl (compile 'com.yubico:u2flib-server-core:0.16.0')
		let registerResponse = u2f._decodeRegisterResponse({
			clientData: "dummy",
			registrationData: "BQRUb_WfRhQCbhg3taktvpvtHOlGaPvaLiHUBrL71JpLzMvK4V_U9Q4cwKNdhtscM3g7VkszTDudEZ_8oOnoY1BRQMdjkqXu2j1WUjPtc0pFU8PeQd3FSIPk3RF663RhtUuVFp94mRogR2O7opbkQXumPOouLbriKZqIPebdbcVTn2kwggJDMIIBLaADAgECAgQX8O1GMAsGCSqGSIb3DQEBCzAuMSwwKgYDVQQDEyNZdWJpY28gVTJGIFJvb3QgQ0EgU2VyaWFsIDQ1NzIwMDYzMTAgFw0xNDA4MDEwMDAwMDBaGA8yMDUwMDkwNDAwMDAwMFowKTEnMCUGA1UEAwweWXViaWNvIFUyRiBFRSBTZXJpYWwgNDAxNjY1MzUwMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEQ-o66R9AJgeKoH6g3FI_WXmvdxUFy__TAreJbnl45E32rKCLQMy2nnKllZs1VfZX136Ff_pQLhUr2BB0C69RpaM7MDkwIgYJKwYBBAGCxAoCBBUxLjMuNi4xLjQuMS40MTQ4Mi4xLjIwEwYLKwYBBAGC5RwCAQEEBAMCBDAwCwYJKoZIhvcNAQELA4IBAQAvwnBqkckkOuQ35S9TJNDHSuAqdwQwRJbeF4KBDEG3ZNHdb1AcS5GL1FfzCGIiCAYVpMvaQZShExivRC204PlK7yj4zLCFds0eF7U6GH9h6JNxZnLXGcXBACk653kzkHBn7LvLIps4U--50K2w0gBQu5HM-B1ev_XXc0MDD4WWwlsY1SdL_w_OFQ-jo5uWCD_surmS-Iqcu5VlZntWzPdIpSeFznGGj7dpGzB676fQsQOizggEB0ikWmur8SqijlrNcMFAlvq0eNAzWNRDCu78b6ad1anwrAEKcanqQDrh4BbEPel9P_Gs6Ft94HYPxkfLFPFeaMJdwASMeXdV8SYVMEUCIEstAWacptwmD8f7_nN0mxag92DBFL4MjlizGmvdTpbYAiEAsb38FNfO4o1Du6Hz0H2zgZACgFSyDxXS8O1fOxSr1m4"
		})
		o(Array.from(registerResponse.userPublicKey)).deepEquals(Array.from(base64ToUint8Array(base64UrlToBase64("BFRv9Z9GFAJuGDe1qS2-m-0c6UZo-9ouIdQGsvvUmkvMy8rhX9T1DhzAo12G2xwzeDtWSzNMO50Rn_yg6ehjUFE"))))
		o(Array.from(registerResponse.keyHandle)).deepEquals(Array.from(base64ToUint8Array(base64UrlToBase64("x2OSpe7aPVZSM-1zSkVTw95B3cVIg-TdEXrrdGG1S5UWn3iZGiBHY7uiluRBe6Y86i4tuuIpmog95t1txVOfaQ"))))

	})
コード例 #10
0
ファイル: AesTest.js プロジェクト: tutao/tutanota
	o("decryptMissingMac 128", function () {
		let key = [151050668, 1341212767, 316219065, 2150939763]
		let iv = new Uint8Array([233, 159, 225, 105, 170, 223, 70, 218, 139, 107, 71, 91, 179, 231, 239, 102])
		let encrypted = aes128Encrypt(key, stringToUtf8Uint8Array("hello"), iv, true, false)
		encrypted = concat(new Uint8Array([1]), encrypted)
		try {
			aes128Decrypt(key, encrypted, true)
		} catch (e) {
			o(e instanceof CryptoError).equals(true)
			o(e.message).equals("invalid mac")
		}
	})
コード例 #11
0
ファイル: RsaTest.js プロジェクト: tutao/tutanota
	o("rsa key roundtrip", function () {

		let keyPair = _getKeyPair()

		let hexPrivateKey = privateKeyToHex(keyPair.privateKey)
		o(hexPrivateKey).equals(privateKeyToHex(hexToPrivateKey(hexPrivateKey)))

		let hexPublicKey = publicKeyToHex(keyPair.publicKey)
		o(hexPublicKey).equals(publicKeyToHex(hexToPublicKey(hexPublicKey)))

		let plain = hexToUint8Array("88888888888888888888888888888888") // = 16 byte sym key

		let encrypted = rsaEncryptSync(keyPair.publicKey, plain, random.generateRandomData(32))
		let plainAgain = rsaDecryptSync(keyPair.privateKey, encrypted)
		o(Array.from(plainAgain)).deepEquals(Array.from(plain))
	})
コード例 #12
0
ファイル: RsaTest.js プロジェクト: tutao/tutanota
	o("oaep pad ", function () {
		let value = [1, 2, 3, 4]
		// random seed and resulting block taken from Java reference test debugging
		let seed = [
			105, 117, -108, -12, 80, 20, -84, -108, 113, 44, 74, 19, -126, -110, -84, 124, 58, 108, 86, 28, 5, -3, -65, -76, 80, -4, -66, 12, -14, -33, -84, 13
		]
		let block = [
			95, -18, 112, -22, -48, -67, 43, 71, -43, 99, -112, 5, -36, 1, 120, -109, -119, -91, 113, 112, -42, -22, -31, 31, -17, 47, 32, -2, -112, -62, -53,
			51, 98, 99, -58, 62, 91, -24, 35, -37, 53, 66, -18, -68, -39, -38, 91, -124, -27, 68, -10, 39, 40, -45, 87, -64, -90, 58, -3, -39, 1, 89, -75, -88,
			121, -72, 40, -14, 88, 107, 7, -117, 70, 46, -7, -49, -117, 36, 98, 39, -128, 79, -63, -94, -81, -57, -71, -43, -13, 10, -69, -54, -99, 2, 21, -49,
			89, 84, 111, -121, 108, 23, -107, 55, -6, 62, -86, 74, 6, 9, 58, -71, 11, 96, -115, 120, -83, 30, -63, -125, 29, 67, -80, 15, 62, -111, -40, -6, 32,
			72, -5, -113, -66, -33, -91, -47, -42, -104, -61, 107, -53, 105, 78, 96, 100, 61, -94, -28, -38, -87, -44, -125, 29, 85, -108, 93, 121, -83, 63, 16,
			9, -10, 123, 86, -89, -42, 30, -51, -44, 30, -46, -84, 6, -87, -83, -117, -100, -10, 99, -53, -86, -38, -70, -116, 98, -57, -101, 60, 67, 27, -81,
			99, -44, 74, -74, -29, 85, 78, -17, -74, 76, 47, 97, 120, -40, 91, 91, -57, 35, -84, 28, -68, 80, 90, -91, 95, 24, -69, 96, -107, -31, -100, -33,
			54, -39, -118, -28, -23, -31, -80, -30, 94, -13, 26, 56, 41, -32, 50, 14, 63, -119, -105, 106, -99, 1, -35, -43, 82, 68, -4, -94, 46, 36, -33, 67
		]
		// convert unsigned bytes from Java to numbers
		for (let i = 0; i < seed.length; i++) {
			if (seed[i] < 0) {
				seed[i] = 256 + seed[i]
			}
		}
		for (let i = 0; i < block.length; i++) {
			if (block[i] < 0) {
				block[i] = 256 + block[i]
			}
		}
		let padded = oaepPad(new Uint8Array(value), 2048, new Uint8Array(seed))
		o(Array.from(padded)).deepEquals(block)
	})
コード例 #13
0
ファイル: AesTest.js プロジェクト: tutao/tutanota
	o("decryptManipulatedData 128 without mac", function () {
		let key = [151050668, 1341212767, 316219065, 2150939763]
		let iv = new Uint8Array([233, 159, 225, 105, 170, 223, 70, 218, 139, 107, 71, 91, 179, 231, 239, 102])
		let encrypted = aes128Encrypt(key, stringToUtf8Uint8Array("hello"), iv, true, false)
		encrypted[0] = encrypted[0] + 1
		let decrypted = aes128Decrypt(key, encrypted, true)
		o(utf8Uint8ArrayToString(decrypted)).equals("kello") // => encrypted data has been manipulated (missing MAC)
	})
コード例 #14
0
ファイル: RsaTest.js プロジェクト: tutao/tutanota
	o("invalid hex key conversion", function (done) {
		let hexPublicKey = "hello"
		try {
			hexToPublicKey(hexPublicKey)
		} catch (e) {
			o(e instanceof CryptoError).equals(true)
			done()
		}
	})
コード例 #15
0
ファイル: RsaTest.js プロジェクト: tutao/tutanota
	o("pss encode ", function () {
		// all values are from PssTest.java for verifying an identical implementation
		let message = hexToUint8Array("b25371601025fcc214c4a6ac877d8db9")
		let seed = hexToUint8Array("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20")

		let padded = encode(message, 2048 - 1, seed)

		let expected = hexToUint8Array("1133b67d48f8c52349f4aa9f72de0625cbc7b2eeffb23f0ad179683a491eb5f68465a61d0b271f9d26a1bb72553a37295f76624dba6dffd809a3a712e31de45c5b4d608e62f9dd58e3c44ec467b8ae570edd14030b79248d9f52271163c488d9ae57e660e473b904c96452508db14711d47d88b5d08be563727b22bc9860ca0c6b5bab789a4056d37f47f457db224de2516a41f7650784ae1033e579e840cf6138e577f9ba2b87fc31697db183178e38e5a2ff03d20f68c4bbc82f8f13fbd7a6a93fe9503701ee985dd53df4c36096b00d06d787001b4887f6134930b4782480de9a9097660193d69d34f1a94ca3df2c3dd3a479c562aea0f496ee6ddf2eefbc")
		o(Array.from(padded)).deepEquals(Array.from(expected))
	})
コード例 #16
0
ファイル: EntityRestCacheTest.js プロジェクト: tutao/tutanota
		o("element is updated in cache", async function () {
			let initialBody = createBodyInstance("id1", "hello")
			cache._putIntoCache(initialBody)

			let bodyUpdate = createBodyInstance("id1", "goodbye")
			clientEntityRequest = function (typeRef, method, listId, id, entity, queryParameter, extraHeaders) {
				o(isSameTypeRef(typeRef, MailBodyTypeRef)).equals(true)
				o(method).equals(HttpMethod.GET)
				o(listId).equals(null)
				o(id).equals(createId("id1"))
				return Promise.resolve(bodyUpdate)
			}

			await cache.entityEventsReceived([createUpdate(MailBodyTypeRef, (null: any), createId("id1"), OperationType.UPDATE)])
			o(clientSpy.callCount).equals(1) // entity is loaded from server
			const body = await cache.entityRequest(MailBodyTypeRef, HttpMethod.GET, null, createId("id1"), null, null)
			o(body.text).equals("goodbye")
			o(clientSpy.callCount).equals(1) // entity is provided from cache
		})
コード例 #17
0
ファイル: MailIndexerTest.js プロジェクト: tutao/tutanota
		o("one mailbox extend once", async function () {
			transaction.put(GroupDataOS, mailGroup, {indexTimestamp: rangeEnd})

			// next index update - continue indexing
			await indexer._indexMailLists([{mbox: mailbox, newestTimestamp: rangeEnd}], rangeEnd2)

			const [mailboxesData2, indexUpdateNew2] = core.writeIndexUpdate.args
			_checkMailsInIndexUpdate(db, indexUpdateNew2, mail1)
			o(mailboxesData2).deepEquals([{groupId: mailGroup, indexTimestamp: rangeEnd2}])
		})
コード例 #18
0
		o("with large length, insufficient memory", function () {
			const entityData = new Uint8Array(256)
			const destinationData = new Uint8Array(2)
			try {
				encodeBinaryBlock(entityData, destinationData, 0)
				throw new Error()
			} catch (e) {
				o(e.constructor).equals(RangeError)
			}
		})
コード例 #19
0
			return Promise.delay(10).then(() => {
				//console.log("finish", cacheCallState)
				if (cacheCallState == "firstEntered") {
					cacheCallState = "firstFinished"
				} else if (cacheCallState == "secondEntered") {
					cacheCallState = "secondFinished"
				} else {
					o(cacheCallState).equals("invalid state found finishing entityEventReceived")
				}
			})
コード例 #20
0
ファイル: FormatterTest.js プロジェクト: Ch4p34uN0iR/tutanota
	o("stringToNameAndMailAddress", function () {
		// test valid strings
		o(stringToNameAndMailAddress(" a@b.de ")).deepEquals({name: "", mailAddress: "*****@*****.**"})
		o(stringToNameAndMailAddress(" <*****@*****.** > ")).deepEquals({name: "", mailAddress: "*****@*****.**"})
		o(stringToNameAndMailAddress(" Aas Bos a@b.de")).deepEquals({name: "Aas Bos", mailAddress: "*****@*****.**"})
		o(stringToNameAndMailAddress(" Aas Bos  <*****@*****.**>")).deepEquals({name: "Aas Bos", mailAddress: "*****@*****.**"})
		o(stringToNameAndMailAddress(" Aas Bos<*****@*****.**>")).deepEquals({name: "Aas Bos", mailAddress: "*****@*****.**"})
		// test invalid strings
		o(stringToNameAndMailAddress(" Aas Bos  <a@de>")).equals(null)
		o(stringToNameAndMailAddress(" Aas Bos ")).equals(null)
		o(stringToNameAndMailAddress(" Aas Bos  a@de")).equals(null)
	})
コード例 #21
0
ファイル: CryptoFacadeTest.js プロジェクト: tutao/tutanota
		o("encrypt boolean value", () => {
			let valueType: ModelValue = createValueType(ValueType.Boolean, true, Cardinality.One)
			let sk = aes128RandomKey()

			let value = false
			let encryptedValue = encryptValue(valueType, value, sk)
			let expected = uint8ArrayToBase64(aes128Encrypt(sk, stringToUtf8Uint8Array(value ? "1" : "0"), base64ToUint8Array(encryptedValue)
				.slice(ENABLE_MAC ? 1 : 0, ENABLE_MAC ? 17 : 16), true, ENABLE_MAC))
			o(encryptedValue).equals(expected)
			o(decryptValue(valueType, encryptedValue, sk)).equals(false)


			value = true
			encryptedValue = encryptValue(valueType, value, sk)
			expected = uint8ArrayToBase64(aes128Encrypt(sk, stringToUtf8Uint8Array(value ? "1" : "0"), base64ToUint8Array(encryptedValue)
				.slice(ENABLE_MAC ? 1 : 0, ENABLE_MAC ? 17 : 16), true, ENABLE_MAC))
			o(encryptedValue).equals(expected)
			o(decryptValue(valueType, encryptedValue, sk)).equals(true)
		})
コード例 #22
0
ファイル: CryptoFacadeTest.js プロジェクト: tutao/tutanota
		o("encrypt date value", () => {
			let valueType: ModelValue = createValueType(ValueType.Date, true, Cardinality.One)
			let sk = aes128RandomKey()
			let value = new Date()

			let encryptedValue = encryptValue(valueType, value, sk)
			let expected = uint8ArrayToBase64(aes128Encrypt(sk, stringToUtf8Uint8Array(value.getTime().toString()), base64ToUint8Array(encryptedValue)
				.slice(ENABLE_MAC ? 1 : 0, ENABLE_MAC ? 17 : 16), true, ENABLE_MAC))
			o(decryptValue(valueType, encryptedValue, sk)).deepEquals(value)
		})
コード例 #23
0
ファイル: EntityRestCacheTest.js プロジェクト: tutao/tutanota
				return cache.entityEventsReceived([createUpdate(MailTypeRef, "listId1", createId("id2"), OperationType.DELETE)]).then(() => {
					o(clientSpy.callCount).equals(1) // entity is not loaded from server
					return cache.entityRequest(MailTypeRef, HttpMethod.GET, "listId1", null, null, {
						start: GENERATED_MIN_ID,
						count: "4",
						reverse: "false"
					}).then(mails => {
						o(mails).deepEquals([originalMails[0], originalMails[2]])
					})
				})
コード例 #24
0
ファイル: FormatterTest.js プロジェクト: Ch4p34uN0iR/tutanota
	o(" mailAddressToFirstAndLastName", function () {
		o(mailAddressToFirstAndLastName("*****@*****.**")).deepEquals({firstName: "Peter", lastName: "Pan"})
		o(mailAddressToFirstAndLastName("*****@*****.**")).deepEquals({firstName: "Peter", lastName: "Pan"})
		o(mailAddressToFirstAndLastName("*****@*****.**")).deepEquals({firstName: "Peter", lastName: "Pan"})
		o(mailAddressToFirstAndLastName("*****@*****.**")).deepEquals({firstName: "Peter", lastName: "Pan"})
		o(mailAddressToFirstAndLastName("*****@*****.**")).deepEquals({firstName: "Peter", lastName: "Pan"})
		o(mailAddressToFirstAndLastName("*****@*****.**")).deepEquals({firstName: "Peter", lastName: "Pater Pan"})
		o(mailAddressToFirstAndLastName("*****@*****.**")).deepEquals({firstName: "Peter", lastName: ""})
	})
コード例 #25
0
		return facade.store().then(() => {
			o(transactionMock.put.args[0]).equals(SearchTermSuggestionsOS)
			o(transactionMock.put.args[1]).equals("contact")
			let encSuggestions = transactionMock.put.args[2]
			facade.addSuggestions(["accc", "bbbb"])
			// insert new values
			o(facade.getSuggestions("a").join(" ")).equals("aaaa accc")
			o(facade.getSuggestions("b").join(" ")).equals("bbbb")

			let transactionLoadMock = {}
			db.dbFacade.createTransaction = o.spy(() => Promise.resolve(transactionLoadMock))
			transactionLoadMock.get = o.spy(() => Promise.resolve(encSuggestions))
			return facade.load().then(() => {
				// restored
				o(transactionLoadMock.get.args[0]).equals(SearchTermSuggestionsOS)
				o(transactionLoadMock.get.args[1]).equals("contact")
				o(facade.getSuggestions("a").join(" ")).equals("aaaa")
				o(facade.getSuggestions("b").join(" ")).equals("")
			})
		})
コード例 #26
0
	o.spec("appendBinaryBlocks", function () {
		o("resizes when needed", function () {
			const row = new Uint8Array([0x01, 0x02])
			const newDataOne = new Uint8Array(256).fill(2)
			const newDataTwo = new Uint8Array([0x01])

			const expected = concat(new Uint8Array([0x01, 0x02]), new Uint8Array([0x82, 0x01, 0x00]), newDataOne, new Uint8Array([0x01, 0x01]))

			o(JSON.stringify(appendBinaryBlocks([newDataOne, newDataTwo], row))).equals(JSON.stringify(expected))
		})
	})
コード例 #27
0
ファイル: MailIndexerTest.js プロジェクト: tutao/tutanota
		o("one mailbox extend till end", async function () {
			transaction.put(GroupDataOS, mailGroup, {indexTimestamp: rangeEnd2})

			// next index update - finish indexing
			const rangeEnd3 = getDayShifted(new Date(rangeEnd2), -1).getTime()

			await indexer._indexMailLists([{mbox: mailbox, newestTimestamp: rangeEnd2}], rangeEnd3)
			const [mailboxesData3, indexUpdateNew3] = core.writeIndexUpdate.args
			_checkMailsInIndexUpdate(db, indexUpdateNew3, mail0)
			o(mailboxesData3).deepEquals([{groupId: mailGroup, indexTimestamp: FULL_INDEXED_TIMESTAMP}])
		})
コード例 #28
0
ファイル: ElectronUpdaterTest.js プロジェクト: tutao/tutanota
        setTimeout(() => {
            //request key
            o(electronMock.net.request.callCount).equals(1)
            o(electronMock.net.request.args[0]).equals('https://b.s')
            o(n.spyify(conn200).end.callCount).equals(1)
            o(n.spyify(conn200).on.callCount).equals(2)
            o(n.spyify(response200).on.callCount).equals(3)

            o(autoUpdaterMock.checkForUpdates.callCount).equals(1)

            // don't check signature
            o(forgeMock.pki.publicKeyFromPem.callCount).equals(0)
            o(n.spyify(key).verify.callCount).equals(0)

            // don't show notification
            o(notifierMock.showOneShot.callCount).equals(0)
            o(autoUpdaterMock.quitAndInstall.callCount).equals(0)
            done()
            upd._stopPolling() // makes the test halt
        }, 190)
コード例 #29
0
ファイル: EntityRestCacheTest.js プロジェクト: tutao/tutanota
	o("loadMultiple", async function () {
		const listId = "listId"
		const inCache = [createMailInstance(listId, "1", "1"), createMailInstance(listId, "3", "3")]
		const notInCache = [createMailInstance(listId, "2", "2"), createMailInstance(listId, "5", "5")]
		inCache.forEach((i) => cache._putIntoCache(i))
		const ids = inCache.concat(notInCache).map(getElementId)

		clientEntityRequest = () => Promise.resolve(notInCache)

		const result = await cache.entityRequest(MailTypeRef, HttpMethod.GET, listId, null, null, {ids: ids.join(",")})

		o(result).deepEquals(notInCache.concat(inCache))
		o(clientSpy.callCount).equals(1)
		o(clientSpy.args).deepEquals(
			[MailTypeRef, HttpMethod.GET, listId, null, null, {ids: notInCache.map(getElementId).join(",")}, undefined]
		)
		inCache.concat(notInCache).forEach((e) => {
			o(cache._isInCache(MailTypeRef, listId, getElementId(e))).equals(true)
		})
	})
コード例 #30
0
ファイル: EntityRestCacheTest.js プロジェクト: tutao/tutanota
	o("load range starting outside of stored range - reverse - read only", async function () {
		let mailFirst = createMailInstance("listId1", "ic5", "subject") // use ids smaller than "id1"
		let mailSecond = createMailInstance("listId1", "ic8", "subject")
		await setupMailList(false, false)
		clientEntityRequest = function (typeRef, method, listId, id, entity, queryParameter, extraHeaders) {
			// load everything from network
			o(queryParameter).deepEquals({start: createId("ic6"), count: "4", reverse: "true"})
			return Promise.resolve([mailFirst])
		}

		const result = await cache.entityRequest(MailTypeRef, HttpMethod.GET, "listId1", null, null, {
			start: createId("ic6"),
			count: "4",
			reverse: "true"
		}, readOnlyHeaders())

		o(result).deepEquals([clone(mailFirst)])
		o(cache._getFromCache(MailTypeRef, getListId(mailFirst), getElementId(mailFirst))).deepEquals(undefined)
		o(clientSpy.callCount).equals(2) // entities are provided from server
	})