@@ -47,7 +47,7 @@ describe 'Utils', () ->
47
47
text = """
48
48
cypher queries
49
49
will often be more
50
- legible on multiple lines
50
+ legible on multiple lines
51
51
than squashed onto a single line
52
52
"""
53
53
expect (Utils .firstWord text).toBe ' cypher'
@@ -119,22 +119,30 @@ describe 'Utils', () ->
119
119
expect (Utils .cleanHTML text).toBe ' hello <p>xxx</p>'
120
120
121
121
it ' should respect whitelist from server' , ->
122
- host = ' http://first.com'
123
- whitelist = ' http://second.com,http://third.com'
124
- expect (Utils .hostIsAllowed host, ' *' ).toBe yes
125
- expect (Utils .hostIsAllowed host, null ).toBe no
126
- expect (Utils .hostIsAllowed host, ' ' ).toBe no
127
- expect (Utils .hostIsAllowed host, host).toBe yes
128
- expect (Utils .hostIsAllowed host, whitelist).toBe no
129
- expect (Utils .hostIsAllowed ' http://guides.neo4j.com' , null ).toBe yes
130
- expect (Utils .hostIsAllowed ' http://guides.neo4j.com' , ' ' ).toBe yes
122
+ whitelist = ' https://second.com,fourth.com'
123
+ expect (Utils .hostIsAllowed ' http://first.com' , whitelist).toBe no
124
+ expect (Utils .hostIsAllowed ' http://second.com' , whitelist).toBe no
125
+ expect (Utils .hostIsAllowed ' https://second.com' , whitelist).toBe yes
126
+ expect (Utils .hostIsAllowed ' http://fourth.com' , whitelist).toBe yes
127
+ expect (Utils .hostIsAllowed ' https://fourth.com' , whitelist).toBe yes
128
+
129
+ it ' should treat * from server as all hosts allowed' , ->
130
+ expect (Utils .hostIsAllowed ' anything' , ' *' ).toBe yes
131
+
132
+ it ' should use defaults if no whitelist specified' , ->
133
+ expect (Utils .hostIsAllowed ' http://anything.com' , null ).toBe no
134
+ expect (Utils .hostIsAllowed ' http://anything.com' , ' ' ).toBe no
135
+ expect (Utils .hostIsAllowed ' guides.neo4j.com' , null ).toBe yes
136
+ expect (Utils .hostIsAllowed ' guides.neo4j.com' , ' ' ).toBe yes
137
+ expect (Utils .hostIsAllowed ' localhost' , ' ' ).toBe yes
138
+ expect (Utils .hostIsAllowed ' localhost' , ' ' ).toBe yes
131
139
132
140
it ' should merge two arrays with documents without duplicates' , ->
133
141
arr1 = [getDocument (' MATCH (n) RETURN n' ), getDocument (' //My script\n RETURN "me"' )]
134
142
arr2 = [getDocument (' MATCH (n)-(m) RETURN n' ), getDocument (' //My script\n RETURN "me"' ), getDocument (' RETURN 1' )]
135
143
expect (JSON .stringify (Utils .mergeDocumentArrays (arr1, arr2)))
136
- .toBe (JSON .stringify ([getDocument (' MATCH (n) RETURN n' ),
137
- getDocument (' //My script\n RETURN "me"' ),
144
+ .toBe (JSON .stringify ([getDocument (' MATCH (n) RETURN n' ),
145
+ getDocument (' //My script\n RETURN "me"' ),
138
146
getDocument (' MATCH (n)-(m) RETURN n' ),
139
147
getDocument (' RETURN 1' )]))
140
148
@@ -155,7 +163,7 @@ describe 'Utils', () ->
155
163
{location : ' http://neo4j.com/?param=' , paramName : ' param' , expect : undefined },
156
164
{location : ' http://neo4j.com/' , paramName : ' param' , expect : undefined }
157
165
]
158
- urls .forEach ((tCase ) ->
166
+ urls .forEach ((tCase ) ->
159
167
res = Utils .getUrlParam tCase .paramName , tCase .location
160
168
val = if res then res[0 ] else res
161
169
expect (val).toBe (tCase .expect )
0 commit comments