Skip to content

Commit 4693b9c

Browse files
author
Michael Perrotte
committedSep 28, 2019
test: moved all github url tests together
1 parent a03d51e commit 4693b9c

File tree

2 files changed

+41
-44
lines changed

2 files changed

+41
-44
lines changed
 

‎test/github.js

+41
Original file line numberDiff line numberDiff line change
@@ -292,5 +292,46 @@ test('fromUrl(github url)', function (t) {
292292

293293
t.equal(HostedGit.fromUrl('git+ssh://github.com/foo.git'), undefined)
294294

295+
t.test('HTTPS GitHub URL with embedded auth -- generally not a good idea', function (tt) {
296+
function verify (host, label, branch) {
297+
var hostinfo = HostedGit.fromUrl(host)
298+
var hash = branch ? '#' + branch : ''
299+
tt.ok(hostinfo, label)
300+
if (!hostinfo) return
301+
tt.is(hostinfo.https(), 'git+https://user:pass@github.com/111/222.git' + hash, label + ' -> https')
302+
tt.is(hostinfo.git(), 'git://user:pass@github.com/111/222.git' + hash, label + ' -> git')
303+
tt.is(hostinfo.browse(), 'https://github.com/111/222' + (branch ? '/tree/' + branch : ''), label + ' -> browse')
304+
tt.is(hostinfo.browse('C'), 'https://github.com/111/222/tree/' + (branch || 'master') + '/C', label + ' -> browse(path)')
305+
tt.is(hostinfo.browse('C/D'), 'https://github.com/111/222/tree/' + (branch || 'master') + '/C/D', label + ' -> browse(path)')
306+
tt.is(hostinfo.browse('C', 'A'), 'https://github.com/111/222/tree/' + (branch || 'master') + '/C#a', label + ' -> browse(path, fragment)')
307+
tt.is(hostinfo.browse('C/D', 'A'), 'https://github.com/111/222/tree/' + (branch || 'master') + '/C/D#a', label + ' -> browse(path, fragment)')
308+
tt.is(hostinfo.bugs(), 'https://github.com/111/222/issues', label + ' -> bugs')
309+
tt.is(hostinfo.docs(), 'https://github.com/111/222' + (branch ? '/tree/' + branch : '') + '#readme', label + ' -> docs')
310+
tt.is(hostinfo.ssh(), 'git@github.com:111/222.git' + hash, label + ' -> ssh')
311+
tt.is(hostinfo.sshurl(), 'git+ssh://git@github.com/111/222.git' + hash, label + ' -> sshurl')
312+
tt.is(hostinfo.shortcut(), 'github:111/222' + hash, label + ' -> shortcut')
313+
tt.is(hostinfo.file('C'), 'https://user:pass@raw.githubusercontent.com/111/222/' + (branch || 'master') + '/C', label + ' -> file')
314+
tt.is(hostinfo.file('C/D'), 'https://user:pass@raw.githubusercontent.com/111/222/' + (branch || 'master') + '/C/D', label + ' -> file')
315+
}
316+
317+
// insecure protocols
318+
verify('git://user:pass@github.com/111/222', 'git')
319+
verify('git://user:pass@github.com/111/222.git', 'git.git')
320+
verify('git://user:pass@github.com/111/222#branch', 'git#branch', 'branch')
321+
verify('git://user:pass@github.com/111/222.git#branch', 'git.git#branch', 'branch')
322+
323+
verify('https://user:pass@github.com/111/222', 'https')
324+
verify('https://user:pass@github.com/111/222.git', 'https.git')
325+
verify('https://user:pass@github.com/111/222#branch', 'https#branch', 'branch')
326+
verify('https://user:pass@github.com/111/222.git#branch', 'https.git#branch', 'branch')
327+
328+
verify('http://user:pass@github.com/111/222', 'http')
329+
verify('http://user:pass@github.com/111/222.git', 'http.git')
330+
verify('http://user:pass@github.com/111/222#branch', 'http#branch', 'branch')
331+
verify('http://user:pass@github.com/111/222.git#branch', 'http.git#branch', 'branch')
332+
333+
tt.end()
334+
})
335+
295336
t.end()
296337
})

‎test/https-with-inline-auth.js

-44
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.