diff --git a/spec/common/importers/lastpassCsvImporter.spec.ts b/spec/common/importers/lastpassCsvImporter.spec.ts index 9235226ca8..c356570c49 100644 --- a/spec/common/importers/lastpassCsvImporter.spec.ts +++ b/spec/common/importers/lastpassCsvImporter.spec.ts @@ -1,9 +1,27 @@ import { LastPassCsvImporter as Importer } from '../../../src/importers/lastpassCsvImporter'; +import { ImportResult } from '../../../src/models/domain/importResult'; import { CipherView } from '../../../src/models/view/cipherView'; import { FieldView } from '../../../src/models/view/fieldView'; -import { FieldType } from '../../../src/enums'; +import { CipherType, FieldType } from '../../../src/enums'; + +function baseExcept(result: ImportResult) { + expect(result).not.toBeNull(); + expect(result.success).toBe(true); + expect(result.ciphers.length).toBe(1); +} + +function expectLogin(cipher: CipherView) { + expect(cipher.type).toBe(CipherType.Login); + + expect(cipher.name).toBe('example.com'); + expect(cipher.notes).toBe('super secure notes'); + expect(cipher.login.uri).toBe('http://example.com'); + expect(cipher.login.username).toBe('someUser'); + expect(cipher.login.password).toBe('myPassword'); + expect(cipher.login.totp).toBe('Y64VEVMBTSXCYIWRSHRNDZW62MPGVU2G'); +} const CipherData = [ { @@ -168,4 +186,16 @@ describe('Lastpass CSV Importer', () => { } }); }); -}); + + it('should parse login with totp', async () => { + const input = `url,username,password,totp,extra,name,grouping,fav + http://example.com,someUser,myPassword,Y64VEVMBTSXCYIWRSHRNDZW62MPGVU2G,super secure notes,example.com,,0`; + + const importer = new Importer(); + const result = await importer.parse(input); + baseExcept(result); + + const cipher = result.ciphers[0]; + expectLogin(cipher); + }); +}); \ No newline at end of file diff --git a/src/importers/lastpassCsvImporter.ts b/src/importers/lastpassCsvImporter.ts index 5abee25fe2..3f8b2a929d 100644 --- a/src/importers/lastpassCsvImporter.ts +++ b/src/importers/lastpassCsvImporter.ts @@ -49,6 +49,7 @@ export class LastPassCsvImporter extends BaseImporter implements Importer { cipher.login.uris = this.makeUriArray(value.url); cipher.login.username = this.getValueOrDefault(value.username); cipher.login.password = this.getValueOrDefault(value.password); + cipher.login.totp = this.getValueOrDefault(value.totp); } else if (cipher.type === CipherType.SecureNote) { this.parseSecureNote(value, cipher); } else if (cipher.type === CipherType.Card) {