@@ -19,6 +19,64 @@ describe('Client', function() {
1919 expect ( ret . host ) . to . equal ( 'example.com' ) ;
2020 } ) ;
2121
22+ // NOTE: At this time, username is always required
23+ // it('can parse host and port', function() {
24+ // ret = client.parse('example.com:12345');
25+ // expect(ret.host).to.equal('example.com');
26+ // expect(ret.port).to.equal('12345');
27+ // });
28+
29+ it ( 'can parse username, host, and port' , function ( ) {
30+ ret = client . parse ( 'admin@example.com:12345' ) ;
31+ expect ( ret . username ) . to . equal ( 'admin' ) ;
32+ expect ( ret . host ) . to . equal ( 'example.com' ) ;
33+ expect ( ret . port ) . to . equal ( '12345' ) ;
34+ } ) ;
35+
36+ it ( 'can parse username, password, host, and port' , function ( ) {
37+ ret = client . parse ( 'admin:bx%9@example.com:12345' ) ;
38+ expect ( ret . username ) . to . equal ( 'admin' ) ;
39+ expect ( ret . password ) . to . equal ( 'bx%9' ) ;
40+ expect ( ret . host ) . to . equal ( 'example.com' ) ;
41+ expect ( ret . port ) . to . equal ( '12345' ) ;
42+ } ) ;
43+
44+ // NOTE: At this time, username is always required
45+ // it('can parse path only', function() {
46+ // ret = client.parse('/home/admin/path');
47+ // expect(ret.path).to.equal('/home/admin/path');
48+ // });
49+
50+ // NOTE: At this time, username is always required
51+ // it('can parse host and path', function() {
52+ // ret = client.parse('example.com:/home/admin/path');
53+ // expect(ret.host).to.equal('example.com');
54+ // expect(ret.path).to.equal('/home/admin/path');
55+ // });
56+
57+ // NOTE: At this time, username is always required
58+ // it('can parse host, port, and path', function() {
59+ // ret = client.parse('example.com:12345:/home/admin/path');
60+ // expect(ret.host).to.equal('example.com');
61+ // expect(ret.port).to.equal('12345');
62+ // expect(ret.path).to.equal('/home/admin/path');
63+ // });
64+
65+ it ( 'can parse username, host, and path' , function ( ) {
66+ ret = client . parse ( 'admin@example.com:/home/admin/path' ) ;
67+ expect ( ret . username ) . to . equal ( 'admin' ) ;
68+ expect ( ret . host ) . to . equal ( 'example.com' ) ;
69+ expect ( ret . path ) . to . equal ( '/home/admin/path' ) ;
70+ } ) ;
71+
72+ it ( 'can parse username, host, port, and path' , function ( ) {
73+ ret = client . parse ( 'admin@example.com:12345:/home/admin/path' ) ;
74+ expect ( ret . username ) . to . equal ( 'admin' ) ;
75+ expect ( ret . host ) . to . equal ( 'example.com' ) ;
76+ expect ( ret . port ) . to . equal ( '12345' ) ;
77+ expect ( ret . path ) . to . equal ( '/home/admin/path' ) ;
78+ } ) ;
79+
2280 it ( 'can parse username, password, host, and path' , function ( ) {
2381 ret = client . parse ( 'admin:bx%9@example.com:/home/admin/path' ) ;
2482 expect ( ret . username ) . to . equal ( 'admin' ) ;
@@ -27,6 +85,41 @@ describe('Client', function() {
2785 expect ( ret . path ) . to . equal ( '/home/admin/path' ) ;
2886 } ) ;
2987
88+ it ( 'can parse username, password, host, port, and path' , function ( ) {
89+ ret = client . parse ( 'admin:bx%9@example.com:12345:/home/admin/path' ) ;
90+ expect ( ret . username ) . to . equal ( 'admin' ) ;
91+ expect ( ret . password ) . to . equal ( 'bx%9' ) ;
92+ expect ( ret . host ) . to . equal ( 'example.com' ) ;
93+ expect ( ret . port ) . to . equal ( '12345' ) ;
94+ expect ( ret . path ) . to . equal ( '/home/admin/path' ) ;
95+ } ) ;
96+
97+ it ( 'can handle "@" in password' , function ( ) {
98+ ret = client . parse ( 'admin:bx@%9@example.com:12345:/home/admin/path' ) ;
99+ expect ( ret . username ) . to . equal ( 'admin' ) ;
100+ expect ( ret . password ) . to . equal ( 'bx@%9' ) ;
101+ expect ( ret . host ) . to . equal ( 'example.com' ) ;
102+ expect ( ret . port ) . to . equal ( '12345' ) ;
103+ expect ( ret . path ) . to . equal ( '/home/admin/path' ) ;
104+ } ) ;
105+
106+ it ( 'can handle ":" in password' , function ( ) {
107+ ret = client . parse ( 'admin:bx:%9@example.com:12345:/home/admin/path' ) ;
108+ expect ( ret . username ) . to . equal ( 'admin' ) ;
109+ expect ( ret . password ) . to . equal ( 'bx:%9' ) ;
110+ expect ( ret . host ) . to . equal ( 'example.com' ) ;
111+ expect ( ret . port ) . to . equal ( '12345' ) ;
112+ expect ( ret . path ) . to . equal ( '/home/admin/path' ) ;
113+ } ) ;
114+
115+ it ( 'can handle "_" in username' , function ( ) {
116+ ret = client . parse ( 'admin_2:bx%9@example.com:12345:/home/admin/path' ) ;
117+ expect ( ret . username ) . to . equal ( 'admin_2' ) ;
118+ expect ( ret . password ) . to . equal ( 'bx%9' ) ;
119+ expect ( ret . host ) . to . equal ( 'example.com' ) ;
120+ expect ( ret . port ) . to . equal ( '12345' ) ;
121+ expect ( ret . path ) . to . equal ( '/home/admin/path' ) ;
122+ } ) ;
30123
31124} ) ;
32125
0 commit comments