Artifactory-Client
view release on metacpan or search on metacpan
0.8.11 2015/2/11
Added license_information call
0.8.10 2015/2/10
Added calculate_debian_repository_metadata call
0.8.9 2015/2/9
Added calculate_npm_repository_metadata call and extracted a helper method
0.8.8 2015/2/6
Added set_gpg_pass_phrase call
0.8.7 2015/2/5
Added set_gpg_private_key call and refactored methods
0.8.6 2015/2/4
Added get_gpg_public_key call
0.8.5 2015/2/3
Added set_gpg_public_key call
0.8.4 2015/2/2
Added deactivate_master_key_encryption call
0.8.3 2015/1/30
Added activate_master_key_encryption call
0.8.2 2015/1/28
Added get_user_encrypted_password call
Takes path, properties, filename and sha1 then deploys the file. Note that properties are a hashref with key-arrayref
pairs, such as:
$prop = { key1 => ['a'], key2 => ['a', 'b'] }
## deploy\_artifacts\_from\_archive( path => $path, file => $file )
Path is the path on Artifactory, file is path to local archive. Will deploy $file to $path.
## push\_a\_set\_of\_artifacts\_to\_bintray( descriptor => 'foo', gpgPassphrase => 'top\_secret', gpgSign => 'true' )
Push a set of artifacts to Bintray as a version. Uses a descriptor file (that must have 'bintray-info' in it's filename
and a .json extension) that was deployed to artifactory, the call accepts the full path to the descriptor as a
parameter.
## push\_docker\_tag\_to\_bintray( dockerImage => 'jfrog/ubuntu:latest', async => 'true', ... )
Push Docker tag to Bintray. Calculation can be synchronous (the default) or asynchronous. You will need to enter your
Bintray credentials, for more details, please refer to Entering your Bintray credentials.
Retrieve the security configuration (security.xml)
## activate\_master\_key\_encryption
Creates a new master key and activates master key encryption
## deactivate\_master\_key\_encryption
Removes the current master key and deactivates master key encryption
## set\_gpg\_public\_key( key => $string )
Sets the public key that Artifactory provides to Debian clients to verify packages
## get\_gpg\_public\_key
Gets the public key that Artifactory provides to Debian clients to verify packages
## set\_gpg\_private\_key( key => $string )
Sets the private key that Artifactory will use to sign Debian packages
## set\_gpg\_pass\_phrase( $passphrase )
Sets the pass phrase required signing Debian packages using the private key
## create\_token( username => 'johnq', scope => 'member-of-groups:readers' )
Creates an access token
## refresh\_token( grant\_type => 'refresh\_token', refresh\_token => 'fgsg53t3g' )
Refresh an access token to extend its validity. If only the access token and the refresh token are provided (and no
lib/Artifactory/Client.pm view on Meta::CPAN
=cut
sub deploy_artifacts_from_archive {
my ( $self, %args ) = @_;
my $header = { 'X-Explode-Archive' => 'true', };
$args{header} = $header;
return $self->deploy_artifact(%args);
}
=head2 push_a_set_of_artifacts_to_bintray( descriptor => 'foo', gpgPassphrase => 'top_secret', gpgSign => 'true' )
Push a set of artifacts to Bintray as a version. Uses a descriptor file (that must have 'bintray-info' in it's filename
and a .json extension) that was deployed to artifactory, the call accepts the full path to the descriptor as a
parameter.
=cut
sub push_a_set_of_artifacts_to_bintray {
my ( $self, %args ) = @_;
lib/Artifactory/Client.pm view on Meta::CPAN
Removes the current master key and deactivates master key encryption
=cut
sub deactivate_master_key_encryption {
my $self = shift;
my $url = $self->_api_url() . "/system/decrypt";
return $self->post($url);
}
=head2 set_gpg_public_key( key => $string )
Sets the public key that Artifactory provides to Debian clients to verify packages
=cut
sub set_gpg_public_key {
my ( $self, %args ) = @_;
my $key = $args{key};
return $self->_handle_gpg_key( 'public', 'put', content => $key );
}
=head2 get_gpg_public_key
Gets the public key that Artifactory provides to Debian clients to verify packages
=cut
sub get_gpg_public_key {
my $self = shift;
return $self->_handle_gpg_key( 'public', 'get' );
}
=head2 set_gpg_private_key( key => $string )
Sets the private key that Artifactory will use to sign Debian packages
=cut
sub set_gpg_private_key {
my ( $self, %args ) = @_;
my $key = $args{key};
return $self->_handle_gpg_key( 'private', 'put', content => $key );
}
=head2 set_gpg_pass_phrase( $passphrase )
Sets the pass phrase required signing Debian packages using the private key
=cut
sub set_gpg_pass_phrase {
my ( $self, $pass ) = @_;
return $self->_handle_gpg_key( 'passphrase', 'put', 'X-GPG-PASSPHRASE' => $pass );
}
=head2 create_token( username => 'johnq', scope => 'member-of-groups:readers' )
Creates an access token
=cut
sub create_token {
my ( $self, %data ) = @_;
lib/Artifactory/Client.pm view on Meta::CPAN
if (%args) {
return $self->post(
$url,
'Content-Type' => 'application/json',
content => $self->_json->encode( \%args )
);
}
return $self->get($url);
}
sub _handle_gpg_key {
my ( $self, $type, $method, %args ) = @_;
my $url = $self->_api_url() . "/gpg/key/$type";
return $self->$method( $url, %args );
}
sub _handle_repository_reindex {
my ( $self, $endpoint, %args ) = @_;
my $url =
(%args)
? $self->_api_url() . $endpoint . "?"
: $self->_api_url() . $endpoint;
$url .= $self->_stringify_hash( '&', %args ) if (%args);
t/01_unit.t view on Meta::CPAN
local *{'LWP::UserAgent::post'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->build_rename( 'api-test', 'something' );
is( $resp->code, 200, 'build_rename succeeded' );
};
subtest 'distribute_build', sub {
my $client = setup();
my %info = (
gpgPassphrase => 'foobar',
'targetRepo' => 'foobar',
);
local *{'LWP::UserAgent::post'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->distribute_build( 'build_name', 5, %info );
is( $resp->code, 200, 'distribute_build succeeded' );
};
t/01_unit.t view on Meta::CPAN
# no-op, unit test reads no file
};
my $resp = $client->deploy_artifacts_from_archive( file => "$Bin/data/test.xml", path => '/some_path/test.zip' );
is( $resp->code, 200, 'deploy_artifacts_from_archive worked' );
};
subtest 'push_a_set_of_artifacts_to_bintray', sub {
my $client = setup();
my %info = (
descriptor => 'some_path',
gpgPassphrase => 'top_secret',
gpgSign => 'true'
);
local *{'LWP::UserAgent::post'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->push_a_set_of_artifacts_to_bintray(%info);
is( $resp->code, 200, 'push_a_set_of_artifacts_to_bintray' );
};
subtest 'distribute_artifact', sub {
my $client = setup();
my %info = (
publish => 'true',
gpgPassphrase => 'abc',
);
local *{'LWP::UserAgent::post'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->distribute_artifact(%info);
is( $resp->code, 200, 'distribute_artifact' );
};
t/01_unit.t view on Meta::CPAN
)
},
'HTTP::Response'
);
};
my $resp = $client->deactivate_master_key_encryption();
my $url_in_response = $resp->request->uri;
like( $url_in_response, qr|/api/system/decrypt|, 'requsted URL looks sane' );
};
subtest 'set_gpg_public_key', sub {
my $client = setup();
local *{'LWP::UserAgent::put'} = sub {
return bless(
{
'_request' => bless(
{
'_uri' => bless(
do { \( my $o = "http://example.com:7777/artifactory/api/gpg/key/public" ) }, 'URI::http'
),
},
'HTTP::Request'
)
},
'HTTP::Response'
);
};
my $resp = $client->set_gpg_public_key();
my $url_in_response = $resp->request->uri;
like( $url_in_response, qr|/api/gpg/key/public|, 'requsted URL looks sane' );
};
subtest 'get_gpg_public_key', sub {
my $client = setup();
local *{'LWP::UserAgent::get'} = sub {
return bless(
{
'_request' => bless(
{
'_uri' => bless(
do { \( my $o = "http://example.com:7777/artifactory/api/gpg/key/public" ) }, 'URI::http'
),
},
'HTTP::Request'
)
},
'HTTP::Response'
);
};
my $resp = $client->get_gpg_public_key();
my $url_in_response = $resp->request->uri;
like( $url_in_response, qr|/api/gpg/key/public|, 'requsted URL looks sane' );
};
subtest 'set_gpg_private_key', sub {
my $client = setup();
local *{'LWP::UserAgent::put'} = sub {
return bless(
{
'_request' => bless(
{
'_uri' => bless(
do { \( my $o = "http://example.com:7777/artifactory/api/gpg/key/private" ) }, 'URI::http'
),
},
'HTTP::Request'
)
},
'HTTP::Response'
);
};
my $resp = $client->set_gpg_private_key();
my $url_in_response = $resp->request->uri;
like( $url_in_response, qr|/api/gpg/key/private|, 'requsted URL looks sane' );
};
subtest 'set_gpg_pass_phrase', sub {
my $client = setup();
local *{'LWP::UserAgent::put'} = sub {
return bless(
{
'_request' => bless(
{
'_uri' => bless(
do { \( my $o = "http://example.com:7777/artifactory/api/gpg/key/passphrase" ) },
'URI::http'
),
},
'HTTP::Request'
)
},
'HTTP::Response'
);
};
my $resp = $client->set_gpg_pass_phrase('foobar');
my $url_in_response = $resp->request->uri;
like( $url_in_response, qr|/api/gpg/key/passphrase|, 'requsted URL looks sane' );
};
subtest 'create_token', sub {
my $client = setup();
local *{'LWP::UserAgent::post'} = sub {
return $mock_responses{http_200};
};
my $resp = $client->create_token( username => 'johnq', scope => 'member-of-groups:readers' );
is( $resp->code, 200, 'create_token' );
( run in 0.779 second using v1.01-cache-2.11-cpan-df04353d9ac )