Add import of totp from Lastpass (#361)
* Add import of totp from Lastpass * Fixed import as request during review
This commit is contained in:
parent
5b7d918f29
commit
e298ecfee3
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue