import { LoginData } from '@wireapp/api-client/src/auth/' ; import { ClientType } from '@wireapp/api-client/src/client' ; import { LoginSanitizer } from './LoginSanitizer' ; describe ( 'LoginSanitizer' , ( ) => { describe ( '"removeNonPrintableCharacters"' , ( ) => { it ( 'sanitizes login data in-place' , ( ) => { const loginData = { clientType : ClientType . NONE , email : 'me@wire.com\t' , password : '\r\nsecret' , } ; LoginSanitizer . removeNonPrintableCharacters ( loginData ) ; expect ( loginData . email ) . toBe ( 'me@wire.com' ) ; expect ( loginData . password ) . toBe ( '\r\nsecret' ) ; } ) ; it ( 'does not strip non-ASCII' , ( ) => { const loginData = { clientType : ClientType . NONE , email : '😀中文¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨〈⟩〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜‌‍‎‏–—‘’‚“”„†‡‰‹›€@wire.com' , password : ' 😀中文¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨〈⟩〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜‌‍‎‏–—‘’‚“”„†‡‰‹›€' , } ; LoginSanitizer . removeNonPrintableCharacters ( loginData ) ; expect ( loginData . email ) . toBe ( '😀中文¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨〈⟩〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜‌‍‎‏–—‘’‚“”„†‡‰‹›€@wire.com' ) ; expect ( loginData . password ) . toBe ( ' 😀中文¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨〈⟩〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜‌‍‎‏–—‘’‚“”„†‡‰‹›€' ) ; } ) ; it ( 'turns a given password into a string' , ( ) => { const loginData = { clientType : ClientType . NONE , email : 'me@wire.com\t' , password : 1234567890 , } ; LoginSanitizer . removeNonPrintableCharacters ( loginData ) ; expect ( loginData . password ) . toEqual ( jasmine . any ( String ) ) ; } ) ; } ) ; } ) ;