Skip to content
This repository was archived by the owner on Jan 31, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/packagist
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ Install Notes
- The token which you can find on the Packagist profile page
Optional steps:
- Enter the username who the API token belongs to (defaults to the repository owner)
- Enter the host of your Packagist installation (defaults to http://packagist.org), the protocol-prefix is optional and defaults to "http://".
- Enter the host of your Packagist installation (defaults to https://packagist.org), the protocol-prefix is optional and defaults to "http://".

3. Check the "Active" checkbox and click "Update Settings".

For more details about Packagist, visit http://packagist.org/

For more details about Packagist, visit https://packagist.org/
6 changes: 2 additions & 4 deletions lib/services/packagist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class Service::Packagist < Service
white_list :domain, :user

def receive_push
http.ssl[:verify] = false
http_post packagist_url, :payload => generate_json(payload), :username => user, :apiToken => token
end

Expand Down Expand Up @@ -37,14 +36,13 @@ def domain

def full_domain
if data['domain'].to_s == ''
'http://packagist.org'
'https://packagist.org'
else
data['domain']
end.lstrip.sub(/[\/\s]+$/,'')
end.lstrip.sub(/[\/\s]+\z/,'').sub(/\Ahttp:\/\/packagist.org/, 'https://packagist.org')
end

def domain_parts
@domain_parts ||= full_domain.split('://')
end
end

12 changes: 10 additions & 2 deletions test/packagist_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_handles_blank_strings_without_errors
assert_equal 'mojombo', svc.user
assert_equal '5gieo7lwcd8gww800scs', svc.token
assert_equal 'packagist.org', svc.domain
assert_equal 'http', svc.scheme
assert_equal 'https', svc.scheme
end

def test_detects_http_url
Expand Down Expand Up @@ -117,6 +117,15 @@ def test_defaults_to_packagist_domain
assert_equal "packagist.org", svc.domain
end

def test_packagist_forced_to_tls
data = {
'domain' => 'http://packagist.org'
}
svc = service(data, payload)
assert_equal 'packagist.org', svc.domain
assert_equal 'https', svc.scheme
end

def service(*args)
super Service::Packagist, *args
end
Expand Down Expand Up @@ -182,4 +191,3 @@ def payload2
}
end
end