Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
Add import of totp from Lastpass (#361)
Browse files Browse the repository at this point in the history
* Add import of totp from Lastpass

* Fixed import as request during review
  • Loading branch information
djsmith85 committed Apr 28, 2021
1 parent 5b7d918 commit e298ecf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
34 changes: 32 additions & 2 deletions spec/common/importers/lastpassCsvImporter.spec.ts
Original file line number Diff line number Diff line change
@@ -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 = [
{
Expand Down Expand Up @@ -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);
});
});
1 change: 1 addition & 0 deletions src/importers/lastpassCsvImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e298ecf

Please sign in to comment.