From 0e4be6d6e7247ab0584eaa8c018ab423dd1fe0a8 Mon Sep 17 00:00:00 2001 From: Sam Batschelet Date: Sun, 15 Apr 2018 15:52:56 -0400 Subject: [PATCH] WIP add full chain support and update tests. (#46) add full chain TLS support * update tests and travis to use full chain TLS. * Bump version and update change log in prep for new release. * Updade README to reflect new changes. --- .travis.yml | 26 +++++-- Changes | 11 +++ README | 13 +++- README.md | 18 ++++- lib/Net/Etcd.pm | 67 ++++++++++++++--- lib/Net/Etcd/Auth.pm | 2 +- lib/Net/Etcd/Auth/Role.pm | 2 +- lib/Net/Etcd/Auth/RolePermission.pm | 2 +- lib/Net/Etcd/Config.pm | 2 +- lib/Net/Etcd/KV.pm | 2 +- lib/Net/Etcd/KV/Compare.pm | 2 +- lib/Net/Etcd/KV/DeleteRange.pm | 2 +- lib/Net/Etcd/KV/Op.pm | 2 +- lib/Net/Etcd/KV/Put.pm | 2 +- lib/Net/Etcd/KV/Range.pm | 2 +- lib/Net/Etcd/KV/Txn.pm | 2 +- lib/Net/Etcd/Lease.pm | 2 +- lib/Net/Etcd/Maintenance.pm | 2 +- lib/Net/Etcd/Member.pm | 2 +- lib/Net/Etcd/Role/Actions.pm | 109 ++++++++++++++++------------ lib/Net/Etcd/User.pm | 2 +- lib/Net/Etcd/User/Role.pm | 2 +- lib/Net/Etcd/Watch.pm | 2 +- t/01-key_value.t | 30 +++++--- t/02-lease.t | 48 +++++++----- t/03-maint.t | 19 +++-- t/04-txn.t | 50 +++++++++---- t/05-user.t | 50 +++++++------ t/06-watch.t | 44 +++++++---- t/07-member.t | 21 ++++-- t/99-auth.t | 47 ++++++------ t/tls/etcd1-key.pem | 5 ++ t/tls/etcd1.csr | 9 +++ t/tls/etcd1.json | 17 +++++ t/tls/etcd1.pem | 18 +++++ t/tls/server-key.pem | 6 +- t/tls/server.csr | 12 +-- t/tls/server.json | 4 +- t/tls/server.pem | 28 +++---- 39 files changed, 458 insertions(+), 228 deletions(-) create mode 100644 t/tls/etcd1-key.pem create mode 100644 t/tls/etcd1.csr create mode 100644 t/tls/etcd1.json create mode 100644 t/tls/etcd1.pem diff --git a/.travis.yml b/.travis.yml index 8a157c7..2f6edbc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,15 +3,31 @@ addons: hosts: - travis1.local - travis1 + - etcd1 env: global: - - ETCD_VER=v3.3.0 + - PATH=$PATH:/tmp/test-etcd/ + - ETCD_VER=v3.3.3 - ETCDCTL_API=3 - - ETCD_TEST_HOST=127.0.0.1 + - ETCD_TEST_HOST=etcd1 - ETCD_TEST_PORT=2379 - - ETCD_TEST_CAPATH=$BUILD_DIR/t/tls/ca.pem - RELEASE_TESTING=1 - - PATH=$PATH:/tmp/test-etcd/ + - ETCD_NAME=member1 + - ETCD_DEBUG=1 + - ETCD_LISTEN_CLIENT_URLS=https://0.0.0.0:2379 + - ETCD_ADVERTISE_CLIENT_URLS=https://etcd1:2379 + - ETCD_INITIAL_ADVERTISE_PEER_URLS=https://etcd1:2380 + - ETCD_LISTEN_PEER_URLS=https://etcd1:2380 + - ETCD_LISTEN_PEER_URLS=https://0.0.0.0:2380 + - ETCD_PEER_KEY_FILE=${TRAVIS_BUILD_DIR}/t/tls/etcd1-key.pem + - ETCD_PEER_CERT_FILE=${TRAVIS_BUILD_DIR}/t/tls/etcd1.pem + - ETCD_CERT_FILE=${TRAVIS_BUILD_DIR}/t/tls/server.pem + - ETCD_KEY_FILE=${TRAVIS_BUILD_DIR}/t/tls/server-key.pem + - ETCD_TRUSTED_CA_FILE=${TRAVIS_BUILD_DIR}/t/tls/ca.pem + - ETCD_CLIENT_CERT_FILE=${TRAVIS_BUILD_DIR}/t/tls/client.pem + - ETCD_CLIENT_KEY_FILE=${TRAVIS_BUILD_DIR}/t/tls/client-key.pem + - ETCD_CLIENT_CA_FILE=${TRAVIS_BUILD_DIR}/t/tls/ca.pem + - ETCD_PEER_CLIENT_CERT_AUTH=1 language: perl perl: - "5.24" @@ -42,7 +58,7 @@ install: - cpan-install --deps - cpan-install --coverage script: - - /tmp/test-etcd/etcd --name member1 --cert-file=$BUILD_DIR/t/tls/server.pem --key-file=$BUILD_DIR/t/tls/server-key.pem --advertise-client-urls=https://127.0.0.1:2379 --listen-client-urls=https://127.0.0.1:2379 & + - /tmp/test-etcd/etcd & - sleep 3 - perl Makefile.PL - make diff --git a/Changes b/Changes index 1d1956d..15ce0d4 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,15 @@ Revision history for Net::Etcd +0.020 +[ ENHANCEMENTS ] +* Add support for full chain TLS. Fixes GH #42 +* Updated travis tests to use etcd v3.3.3 + +[ BREAKING ] +* Default value for api_version is now /v3beta. + +[ ANNOUNCEMENT ] +* Default value for api_version will change to /v3 on the release of etcd v3.4 + 0.019 [ BUG FIX ] * Resolved issue where chunked data was not properly handled in non streaming calls and would truncate data when buffer was full. Fixed By GH #40 - Thanks Ananth Kavuri (foobargeez) diff --git a/README b/README index dfb371d..3ec78fa 100644 --- a/README +++ b/README @@ -80,14 +80,23 @@ ACCESSORS password Authentication credentials, defaults to $ENV{ETCD_CLIENT_PASSWORD} + ca_file + Path to ca_file, defaults to $ENV{ETCD_CLIENT_CA_FILE} + + key_file + Path to key_file, defaults to $ENV{ETCD_CLIENT_KEY_FILE} + + cert_file + Path to cert_file, defaults to $ENV{ETCD_CLIENT_CERT_FILE} + cacert - Path to cacert, defaults to $ENV{ETCD_CERT_FILE} + Path to cacert, defaults to $ENV{ETCD_CLIENT_CACERT_FILE}. ssl To enable set to 1 api_version - defaults to /v3alpha + defaults to /v3beta api_path The full api path. Defaults to http://127.0.0.1:2379/v3alpha diff --git a/README.md b/README.md index 5c06962..e45153d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Build Status](https://api.travis-ci.org/hexfusion/perl-net-etcd.svg?branch=master)](https://travis-ci.org/hexfusion/perl-net-etcd) - +i # NAME Net::Etcd - etcd v3 REST API. @@ -89,9 +89,21 @@ Username for authentication, defaults to $ENV{ETCD\_CLIENT\_USERNAME} Authentication credentials, defaults to $ENV{ETCD\_CLIENT\_PASSWORD} +## ca\_file + +Path to ca\_file, defaults to $ENV{ETCD\_CLIENT\_CA\_FILE} + +## key\_file + +Path to key\_file, defaults to $ENV{ETCD\_CLIENT\_KEY\_FILE} + +## cert\_file + +Path to cert\_file, defaults to $ENV{ETCD\_CLIENT\_CERT\_FILE} + ## cacert -Path to cacert, defaults to $ENV{ETCD\_CERT\_FILE} +Path to cacert, defaults to $ENV{ETCD\_CLIENT\_CACERT\_FILE}. ## ssl @@ -99,7 +111,7 @@ To enable set to 1 ## api\_version -defaults to /v3alpha +defaults to /v3beta ## api\_path diff --git a/lib/Net/Etcd.pm b/lib/Net/Etcd.pm index 9f30901..c8c9893 100644 --- a/lib/Net/Etcd.pm +++ b/lib/Net/Etcd.pm @@ -1,5 +1,7 @@ use utf8; + package Net::Etcd; + # ABSTRACT: Provide access to the etcd v3 API. use strict; @@ -30,7 +32,7 @@ Net::Etcd - etcd v3 REST API. =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 SYNOPSIS @@ -132,7 +134,7 @@ Username for authentication, defaults to $ENV{ETCD_CLIENT_USERNAME} =cut has name => ( - is => 'ro', + is => 'ro', default => $ENV{ETCD_CLIENT_USERNAME} ); @@ -143,21 +145,55 @@ Authentication credentials, defaults to $ENV{ETCD_CLIENT_PASSWORD} =cut has password => ( - is => 'ro', + is => 'ro', default => $ENV{ETCD_CLIENT_PASSWORD} ); +=head2 ca_file + +Path to ca_file, defaults to $ENV{ETCD_CLIENT_CA_FILE} + +=cut + +has ca_file => ( + is => 'ro', + default => $ENV{ETCD_CLIENT_CA_FILE} +); + +=head2 key_file + +Path to key_file, defaults to $ENV{ETCD_CLIENT_KEY_FILE} + +=cut + +has key_file => ( + is => 'ro', + default => $ENV{ETCD_CLIENT_KEY_FILE} +); + +=head2 cert_file + +Path to cert_file, defaults to $ENV{ETCD_CLIENT_CERT_FILE} + +=cut + +has cert_file => ( + is => 'ro', + default => $ENV{ETCD_CLIENT_CERT_FILE} +); + =head2 cacert -Path to cacert, defaults to $ENV{ETCD_CERT_FILE} +Path to cacert, defaults to $ENV{ETCD_CLIENT_CACERT_FILE}. =cut has cacert => ( - is => 'ro', - default => $ENV{ETCD_CERT_FILE} + is => 'ro', + default => $ENV{ETCD_CLIENT_CACERT_FILE} ); + =head2 ssl To enable set to 1 @@ -171,14 +207,14 @@ has ssl => ( =head2 api_version -defaults to /v3alpha +defaults to /v3beta =cut has api_version => ( is => 'ro', isa => Str, - default => '/v3alpha' + default => '/v3beta' ); =head2 api_path @@ -191,8 +227,15 @@ has api_path => ( is => 'lazy' ); sub _build_api_path { my ($self) = @_; - return ( $self->ssl || $self->cacert ? 'https' : 'http' ) . '://' - . $self->host . ':'. $self->port . $self->api_version; + return ( $self->{ssl} + || $self->{ca_file} + || $self->{key_file} + || $self->{cafile} + || $self->{cert_file} ? 'https' : 'http' ) + . '://' + . $self->host . ':' + . $self->port + . $self->api_version; } =head2 auth_token @@ -276,8 +319,8 @@ sub role_perm { my ( $self, $options ) = @_; my $cb = pop if ref $_[-1] eq 'CODE'; my $perm = Net::Etcd::Auth::RolePermission->new( - etcd => $self, - cb => $cb, + etcd => $self, + cb => $cb, ( $options ? %$options : () ), ); } diff --git a/lib/Net/Etcd/Auth.pm b/lib/Net/Etcd/Auth.pm index de2a348..8b47458 100644 --- a/lib/Net/Etcd/Auth.pm +++ b/lib/Net/Etcd/Auth.pm @@ -26,7 +26,7 @@ Net::Etcd::Auth =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/Auth/Role.pm b/lib/Net/Etcd/Auth/Role.pm index 52bfb59..ca0257a 100644 --- a/lib/Net/Etcd/Auth/Role.pm +++ b/lib/Net/Etcd/Auth/Role.pm @@ -20,7 +20,7 @@ Net::Etcd::Auth::Role =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/Auth/RolePermission.pm b/lib/Net/Etcd/Auth/RolePermission.pm index c66af49..e8deeff 100644 --- a/lib/Net/Etcd/Auth/RolePermission.pm +++ b/lib/Net/Etcd/Auth/RolePermission.pm @@ -21,7 +21,7 @@ Net::Etcd::Auth::RolePermission =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/Config.pm b/lib/Net/Etcd/Config.pm index efb37bb..ffec8a6 100644 --- a/lib/Net/Etcd/Config.pm +++ b/lib/Net/Etcd/Config.pm @@ -13,7 +13,7 @@ Net::Etcd::Config =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 ACCESSORS diff --git a/lib/Net/Etcd/KV.pm b/lib/Net/Etcd/KV.pm index ad2d38a..6b41fcc 100644 --- a/lib/Net/Etcd/KV.pm +++ b/lib/Net/Etcd/KV.pm @@ -25,7 +25,7 @@ Net::Etcd::KV =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/KV/Compare.pm b/lib/Net/Etcd/KV/Compare.pm index 3ad9c5d..02cc6b4 100644 --- a/lib/Net/Etcd/KV/Compare.pm +++ b/lib/Net/Etcd/KV/Compare.pm @@ -20,7 +20,7 @@ Net::Etcd::KV::Compare =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/KV/DeleteRange.pm b/lib/Net/Etcd/KV/DeleteRange.pm index 49a8a18..0e06522 100644 --- a/lib/Net/Etcd/KV/DeleteRange.pm +++ b/lib/Net/Etcd/KV/DeleteRange.pm @@ -19,7 +19,7 @@ Net::Etcd::DeleteRange =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/KV/Op.pm b/lib/Net/Etcd/KV/Op.pm index 78a9b91..288298b 100644 --- a/lib/Net/Etcd/KV/Op.pm +++ b/lib/Net/Etcd/KV/Op.pm @@ -20,7 +20,7 @@ Net::Etcd::KV::Op =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/KV/Put.pm b/lib/Net/Etcd/KV/Put.pm index 8fbd6e8..9947dd2 100644 --- a/lib/Net/Etcd/KV/Put.pm +++ b/lib/Net/Etcd/KV/Put.pm @@ -19,7 +19,7 @@ Net::Etcd::Put =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/KV/Range.pm b/lib/Net/Etcd/KV/Range.pm index 5333e7e..8b04171 100644 --- a/lib/Net/Etcd/KV/Range.pm +++ b/lib/Net/Etcd/KV/Range.pm @@ -19,7 +19,7 @@ Net::Etcd::Range =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/KV/Txn.pm b/lib/Net/Etcd/KV/Txn.pm index 5271b85..424b9f2 100644 --- a/lib/Net/Etcd/KV/Txn.pm +++ b/lib/Net/Etcd/KV/Txn.pm @@ -20,7 +20,7 @@ Net::Etcd::KV::Txn =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/Lease.pm b/lib/Net/Etcd/Lease.pm index da0fb13..f10bc96 100644 --- a/lib/Net/Etcd/Lease.pm +++ b/lib/Net/Etcd/Lease.pm @@ -20,7 +20,7 @@ Net::Etcd::Lease =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/Maintenance.pm b/lib/Net/Etcd/Maintenance.pm index 396a912..e190284 100644 --- a/lib/Net/Etcd/Maintenance.pm +++ b/lib/Net/Etcd/Maintenance.pm @@ -20,7 +20,7 @@ Net::Etcd::Maintenance =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 SYNOPSIS # defrag member's backend database diff --git a/lib/Net/Etcd/Member.pm b/lib/Net/Etcd/Member.pm index 369ea24..65f26f1 100644 --- a/lib/Net/Etcd/Member.pm +++ b/lib/Net/Etcd/Member.pm @@ -20,7 +20,7 @@ Net::Etcd::Maintenance =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 SYNOPSIS # list members diff --git a/lib/Net/Etcd/Role/Actions.pm b/lib/Net/Etcd/Role/Actions.pm index 9b84083..ceba611 100644 --- a/lib/Net/Etcd/Role/Actions.pm +++ b/lib/Net/Etcd/Role/Actions.pm @@ -1,4 +1,5 @@ use utf8; + package Net::Etcd::Role::Actions; use strict; @@ -23,7 +24,7 @@ Net::Etcd::Role::Actions =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; has etcd => ( is => 'ro', @@ -58,7 +59,7 @@ AnyEvent callback must be a CodeRef has cb => ( is => 'ro', isa => sub { - die "$_[0] is not a CodeRef!" if ( $_[0] && ref($_[0]) ne 'CODE') + die "$_[0] is not a CodeRef!" if ( $_[0] && ref( $_[0] ) ne 'CODE' ); }, ); @@ -66,16 +67,14 @@ has cb => ( =cut -has cv => ( - is => 'ro', -); +has cv => ( is => 'ro', ); =head2 init =cut sub init { - my ($self) = @_; + my ($self) = @_; my $init = $self->json_args; $init or return; return $self; @@ -101,19 +100,25 @@ sub _build_headers { return $headers; } -has tls_ctx => ( is => 'lazy', ); +has tls_ctx => ( is => 'lazy', ); sub _build_tls_ctx { - my ($self) = @_; - my $cacert = $self->etcd->cacert; - if ($cacert) { - my $tls =({ - verify => 0, - ca_path => $cacert, - }); + my ($self) = @_; + my $ca_file = $self->etcd->ca_file; + my $key_file = $self->etcd->key_file; + my $cert_file = $self->etcd->cert_file; + my $cacert = $self->etcd->cacert; + my $tls; + $tls->{ca_file} = $ca_file if $ca_file; + $tls->{key_file} = $key_file if $key_file; + $tls->{cert_file} = $cert_file if $cert_file; + $tls->{cacert} = $cacert if $cacert; + + if ( $ca_file || $key_file || $cert_file ) { + $tls->{verify} = 1; return $tls; } - return 'low'; #default + return 'low'; } =head2 hold @@ -149,8 +154,9 @@ has request => ( is => 'lazy', ); sub _build_request { my ($self) = @_; - if ($self->{retry_auth} > 1) { - confess "Error: Unable to authenticate, check your username and password"; + if ( $self->{retry_auth} > 1 ) { + confess + "Error: Unable to authenticate, check your username and password"; $self->{retry_auth} = 0; return; } @@ -162,53 +168,65 @@ sub _build_request { http_request( 'POST', $self->etcd->api_path . $self->{endpoint}, - headers => $self->headers, - body => $self->json_args, - tls_ctx => $self->tls_ctx, + headers => $self->headers, + body => $self->json_args, + tls_ctx => $self->tls_ctx, on_header => sub { - my($headers) = @_; + my ($headers) = @_; $self->{response}{headers} = $headers; }, want_body_handle => 1, sub { - my ($handle, $hdr) = @_; + my ( $handle, $hdr ) = @_; my $json_reader = sub { - my ($handle, $json) = @_; + my ( $handle, $json ) = @_; return unless $json; $self->{response}{content} = JSON::encode_json($json); - $cb->($json, $hdr) if $cb; + $cb->( $json, $hdr ) if $cb; my $status = $hdr->{Status}; $self->check_hdr($status); $cv->send; }; my $chunk_reader = sub { - my($handle, $line) = @_; + my ( $handle, $line ) = @_; return unless $line; + #read chunk size - $line =~ /^([0-9a-fA-F]+)/ or die 'bad chunk (incorrect length) -['.$line.']-'; + $line =~ /^([0-9a-fA-F]+)/ + or die 'bad chunk (incorrect length) -[' . $line . ']-'; my $len = hex $1; + #read chunk - $handle->push_read(chunk => $len, sub { - my($handle, $chunk) = @_; - $handle->push_read(line => sub { - length $_[1] and die 'bad chunk (missing last empty line)'; - }); - $self->{response}{content} = $chunk; - $cb->($chunk, $hdr) if $cb; - my $status = $hdr->{Status}; - $self->check_hdr($status); - $cv->send; - }); + $handle->push_read( + chunk => $len, + sub { + my ( $handle, $chunk ) = @_; + $handle->push_read( + line => sub { + length $_[1] + and die 'bad chunk (missing last empty line)'; + } + ); + $self->{response}{content} = $chunk; + $cb->( $chunk, $hdr ) if $cb; + my $status = $hdr->{Status}; + $self->check_hdr($status); + $cv->send; + } + ); }; - if (($hdr->{'transfer-encoding'} || '') =~ /\bchunked\b/i) { - $handle->on_read(sub {$handle->push_read(line => $chunk_reader)}); - } else { - $handle->on_read(sub {$handle->push_read(json => $json_reader)}); + if ( ( $hdr->{'transfer-encoding'} || '' ) =~ /\bchunked\b/i ) { + $handle->on_read( + sub { $handle->push_read( line => $chunk_reader ) } ); + } + else { + $handle->on_read( + sub { $handle->push_read( json => $json_reader ) } ); } - $handle->on_eof(sub {$handle->destroy; $cv->end}); - $handle->on_error(sub {$handle->destroy; $cv->end}); + $handle->on_eof( sub { $handle->destroy; $cv->end } ); + $handle->on_error( sub { $handle->destroy; $cv->end } ); } ); $cv->recv; @@ -234,6 +252,7 @@ sub get_value { my ($self) = @_; my $response = $self->response; my $content = from_json( $response->{content} ); + #print STDERR Dumper($content); my $value = $content->{kvs}->[0]->{value}; $value or return; @@ -275,7 +294,7 @@ Success is returned if the response is a 200 =cut sub is_success { - my ($self) = @_; + my ($self) = @_; my $response = $self->response; if ( defined $response->{success} ) { return $response->{success}; @@ -304,7 +323,7 @@ check response header then define success and retry_auth. =cut sub check_hdr { - my ($self, $status) = @_; + my ( $self, $status ) = @_; my $success = $status == 200 ? 1 : 0; $self->{response}{success} = $success; $self->{retry_auth}++ if $status == 401; diff --git a/lib/Net/Etcd/User.pm b/lib/Net/Etcd/User.pm index 8b9256c..4289d52 100644 --- a/lib/Net/Etcd/User.pm +++ b/lib/Net/Etcd/User.pm @@ -20,7 +20,7 @@ Net::Etcd::User =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/User/Role.pm b/lib/Net/Etcd/User/Role.pm index 491207d..52c0b6a 100644 --- a/lib/Net/Etcd/User/Role.pm +++ b/lib/Net/Etcd/User/Role.pm @@ -17,7 +17,7 @@ Net::Etcd::User::Role =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/Watch.pm b/lib/Net/Etcd/Watch.pm index ce6a2d2..47576e4 100644 --- a/lib/Net/Etcd/Watch.pm +++ b/lib/Net/Etcd/Watch.pm @@ -20,7 +20,7 @@ Net::Etcd::Range =cut -our $VERSION = '0.019'; +our $VERSION = '0.020'; =head1 DESCRIPTION diff --git a/t/01-key_value.t b/t/01-key_value.t index fa4042b..1e88599 100644 --- a/t/01-key_value.t +++ b/t/01-key_value.t @@ -7,20 +7,26 @@ use Net::Etcd; use Test::More; use Test::Exception; use Data::Dumper; +use Cwd; my $config; - -if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT}) { - $config->{host} = $ENV{ETCD_TEST_HOST}; - $config->{port} = $ENV{ETCD_TEST_PORT}; - $config->{cacert} = $ENV{ETCD_TEST_CAPATH} if $ENV{ETCD_TEST_CAPATH}; +my $dir = getcwd; + +if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT} ) { + $config->{host} = $ENV{ETCD_TEST_HOST}; + $config->{port} = $ENV{ETCD_TEST_PORT}; + $config->{ca_file} = $ENV{ETCD_CLIENT_CA_FILE} || "$dir/t/tls/ca.pem"; + $config->{key_file} = $ENV{ETCD_CLIENT_KEY_FILE} || "$dir/t/tls/client-key.pem"; + $config->{cert_file} = $ENV{ETCD_CLIENT_CERT_FILE} || "$dir/t/tls/client.pem"; + $config->{ssl} = 1; plan tests => 8; } else { - plan skip_all => "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; + plan skip_all => + "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; } -my $etcd = Net::Etcd->new( $config ); +my $etcd = Net::Etcd->new($config); my $key; @@ -34,10 +40,12 @@ lives_ok( cmp_ok( $key->is_success, '==', 1, "kv put success" ); +#print STDERR Dumper($key); + # get range lives_ok( sub { - $key = $etcd->range( { key => 'foo1' } ) + $key = $etcd->range( { key => 'foo1' } ); }, "kv range" ); @@ -49,7 +57,7 @@ cmp_ok( $key->is_success, '==', 1, "kv range success" ); # delete range lives_ok( sub { - $key = $etcd->deleterange( { key => 'foo1' } ) + $key = $etcd->deleterange( { key => 'foo1' } ); }, "kv range_delete" ); @@ -61,11 +69,11 @@ cmp_ok( $key->is_success, '==', 1, "kv delete success" ); # verify delete lives_ok( sub { - $key = $etcd->range( { key => 'foo1' } ) + $key = $etcd->range( { key => 'foo1' } ); }, "kv range against deleted key" ); -is( $key->get_value, undef, "key undef as expected"); +is( $key->get_value, undef, "key undef as expected" ); 1; diff --git a/t/02-lease.t b/t/02-lease.t index 0ac7918..62270f4 100644 --- a/t/02-lease.t +++ b/t/02-lease.t @@ -8,31 +8,38 @@ use Test::More; use Test::Exception; use Math::Int64 qw(int64_rand int64_to_string); use Data::Dumper; +use Cwd; my $config; - -if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT}) { - $config->{host} = $ENV{ETCD_TEST_HOST}; - $config->{port} = $ENV{ETCD_TEST_PORT}; - $config->{cacert} = $ENV{ETCD_TEST_CAPATH} if $ENV{ETCD_TEST_CAPATH}; +my $dir = getcwd; + +if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT} ) { + $config->{host} = $ENV{ETCD_TEST_HOST}; + $config->{port} = $ENV{ETCD_TEST_PORT}; + $config->{ca_file} = $ENV{ETCD_CLIENT_CA_FILE} || "$dir/t/tls/ca.pem"; + $config->{key_file} = $ENV{ETCD_CLIENT_KEY_FILE} || "$dir/t/tls/client-key.pem"; + $config->{cert_file} = $ENV{ETCD_CLIENT_CERT_FILE} || "$dir/t/tls/client.pem"; + $config->{ca_file} = "$dir/t/tls/ca.pem"; + $config->{key_file} = "$dir/t/tls/client-key.pem"; + $config->{cert_file} = "$dir/t/tls/client.pem"; + $config->{ssl} = 1; plan tests => 16; } - else { - plan skip_all => "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; + plan skip_all => + "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; } -my $etcd = Net::Etcd->new( $config ); +my $etcd = Net::Etcd->new($config); my $lease; -my $int64 = int64_rand(); +my $int64 = int64_rand(); my $lease_id = int64_to_string($int64); # add lease lives_ok( sub { - $lease = - $etcd->lease( { ID => $lease_id, TTL => 20 } )->grant; + $lease = $etcd->lease( { ID => $lease_id, TTL => 20 } )->grant; }, "add a new lease" ); @@ -40,8 +47,13 @@ lives_ok( cmp_ok( $lease->is_success, '==', 1, "add lease success" ); # add lease to key -lives_ok( sub { $lease = $etcd->put( { key => 'foo2', value => 'bar2', lease => $lease_id } ) }, - "add a new lease to a key" ); +lives_ok( + sub { + $lease = + $etcd->put( { key => 'foo2', value => 'bar2', lease => $lease_id } ); + }, + "add a new lease to a key" +); cmp_ok( $lease->is_success, '==', 1, "add lease to key success" ); @@ -54,16 +66,15 @@ lives_ok( sub { $key = $etcd->range( { key => 'foo2' } )->get_value }, cmp_ok( $key, 'eq', 'bar2', "lease key value" ); # lease keep alive -lives_ok( sub { $lease = $etcd->lease( { ID => $lease_id } )->keepalive }, +lives_ok( sub { $lease = $etcd->lease( { ID => $lease_id } )->keepalive }, "lease_keep_alive" ); #print STDERR Dumper($lease); - cmp_ok( $lease->is_success, '==', 1, "reset lease keep alive success" ); # lease ttl -lives_ok( sub { $lease = $etcd->lease( { ID => $lease_id, keys => 1 } )->ttl }, +lives_ok( sub { $lease = $etcd->lease( { ID => $lease_id, keys => 1 } )->ttl }, "lease_ttl" ); cmp_ok( $lease->is_success, '==', 1, "return lease_ttl success" ); @@ -71,15 +82,14 @@ cmp_ok( $lease->is_success, '==', 1, "return lease_ttl success" ); #print STDERR Dumper($lease); # lease leases -lives_ok( sub { $lease = $etcd->lease()->leases }, - "lease_leases" ); +lives_ok( sub { $lease = $etcd->lease()->leases }, "lease_leases" ); cmp_ok( $lease->is_success, '==', 1, "return lease_leases success" ); #print STDERR Dumper($lease); # revoke lease -lives_ok( sub { $lease = $etcd->lease( { ID => $lease_id } )->revoke }, +lives_ok( sub { $lease = $etcd->lease( { ID => $lease_id } )->revoke }, "revoke lease" ); #print STDERR Dumper($lease); diff --git a/t/03-maint.t b/t/03-maint.t index a883308..ae58e23 100644 --- a/t/03-maint.t +++ b/t/03-maint.t @@ -6,22 +6,27 @@ use Net::Etcd; use Test::More; use Test::Exception; use Data::Dumper; +use Cwd; my $config; +my $dir = getcwd; -if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT}) { - - $config->{host} = $ENV{ETCD_TEST_HOST}; - $config->{port} = $ENV{ETCD_TEST_PORT}; - $config->{cacert} = $ENV{ETCD_TEST_CAPATH} if $ENV{ETCD_TEST_CAPATH}; +if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT} ) { + $config->{host} = $ENV{ETCD_TEST_HOST}; + $config->{port} = $ENV{ETCD_TEST_PORT}; + $config->{ca_file} = $ENV{ETCD_CLIENT_CA_FILE} || "$dir/t/tls/ca.pem"; + $config->{key_file} = $ENV{ETCD_CLIENT_KEY_FILE} || "$dir/t/tls/client-key.pem"; + $config->{cert_file} = $ENV{ETCD_CLIENT_CERT_FILE} || "$dir/t/tls/client.pem"; + $config->{ssl} = 1; plan tests => 8; } else { - plan skip_all => "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; + plan skip_all => + "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; } my $maint; -my $etcd = Net::Etcd->new( $config ); +my $etcd = Net::Etcd->new($config); # snapshot lives_ok( diff --git a/t/04-txn.t b/t/04-txn.t index a4a76a9..38d0dfb 100644 --- a/t/04-txn.t +++ b/t/04-txn.t @@ -6,31 +6,37 @@ use Net::Etcd; use Test::More; use Test::Exception; use Data::Dumper; +use Cwd; my $config; - -if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT}) { - $config->{host} = $ENV{ETCD_TEST_HOST}; - $config->{port} = $ENV{ETCD_TEST_PORT}; - $config->{cacert} = $ENV{ETCD_TEST_CAPATH} if $ENV{ETCD_TEST_CAPATH}; +my $dir = getcwd; + +if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT} ) { + $config->{host} = $ENV{ETCD_TEST_HOST}; + $config->{port} = $ENV{ETCD_TEST_PORT}; + $config->{ca_file} = $ENV{ETCD_CLIENT_CA_FILE} || "$dir/t/tls/ca.pem"; + $config->{key_file} = $ENV{ETCD_CLIENT_KEY_FILE} || "$dir/t/tls/client-key.pem"; + $config->{cert_file} = $ENV{ETCD_CLIENT_CERT_FILE} || "$dir/t/tls/client.pem"; + $config->{ssl} = 1; plan tests => 14; } else { - plan skip_all => "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; + plan skip_all => + "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; } -my ($put, $comp, $range, @op, @compare, $txn); -my $etcd = Net::Etcd->new( $config ); +my ( $put, $comp, $range, @op, @compare, $txn ); +my $etcd = Net::Etcd->new($config); -my @chars = ("A".."Z", "a".."z"); +my @chars = ( "A" .. "Z", "a" .. "z" ); # gen random key so we can kee[ it realz my $rand_key; -$rand_key .= $chars[rand @chars] for 1..8; +$rand_key .= $chars[ rand @chars ] for 1 .. 8; lives_ok( sub { - $put = $etcd->put( { key => $rand_key , value => 'randy' } ); + $put = $etcd->put( { key => $rand_key, value => 'randy' } ); }, "put random key" ); @@ -57,7 +63,6 @@ lives_ok( #print STDERR Dumper($put); - lives_ok( sub { push @op, $etcd->op( { request_put => $put } ); @@ -69,7 +74,15 @@ lives_ok( lives_ok( sub { - push @compare, $etcd->compare( { key => 'foozilla', result => 'EQUAL', target => 'VALUE', value => 'baz' }); + push @compare, + $etcd->compare( + { + key => 'foozilla', + result => 'EQUAL', + target => 'VALUE', + value => 'baz' + } + ); }, "compare create" ); @@ -94,7 +107,14 @@ undef $txn; lives_ok( sub { - $comp = $etcd->compare( { key => $rand_key, target => 'CREATE', result => 'NOT_EQUAL', create_revision => '0' }); + $comp = $etcd->compare( + { + key => $rand_key, + target => 'CREATE', + result => 'NOT_EQUAL', + create_revision => '0' + } + ); push @compare, $comp; }, "compare create" @@ -102,7 +122,6 @@ lives_ok( #print STDERR Dumper($comp); - lives_ok( sub { $range = $etcd->range( { key => 'foozilla', hold => 1 } ); @@ -125,6 +144,7 @@ lives_ok( ); cmp_ok( $txn->is_success, '==', 1, "txn create cleanup success" ); + #print STDERR Dumper($txn); 1; diff --git a/t/05-user.t b/t/05-user.t index 583c098..72c3090 100644 --- a/t/05-user.t +++ b/t/05-user.t @@ -7,30 +7,33 @@ use Net::Etcd; use Test::More; use Test::Exception; use Data::Dumper; +use Cwd; my $config; - -if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT}) { - $config->{host} = $ENV{ETCD_TEST_HOST}; - $config->{port} = $ENV{ETCD_TEST_PORT}; - $config->{cacert} = $ENV{ETCD_TEST_CAPATH} if $ENV{ETCD_TEST_CAPATH}; - $config->{name} = 'root'; - $config->{password} = 'toor'; +my $dir = getcwd; + +if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT} ) { + $config->{host} = $ENV{ETCD_TEST_HOST}; + $config->{port} = $ENV{ETCD_TEST_PORT}; + $config->{ca_file} = $ENV{ETCD_CLIENT_CA_FILE} || "$dir/t/tls/ca.pem"; + $config->{key_file} = $ENV{ETCD_CLIENT_KEY_FILE} || "$dir/t/tls/client-key.pem"; + $config->{cert_file} = $ENV{ETCD_CLIENT_CERT_FILE} || "$dir/t/tls/client.pem"; + $config->{ssl} = 1; plan tests => 19; } else { - plan skip_all => "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; + plan skip_all => + "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; } -my $etcd = Net::Etcd->new( $config ); +my $etcd = Net::Etcd->new($config); -my ($user, $role); +my ( $user, $role ); # add user lives_ok( sub { - $user = - $etcd->user( { name => 'samba', password => 'foo' } )->add; + $user = $etcd->user( { name => 'samba', password => 'foo' } )->add; }, "add a new user" ); @@ -40,9 +43,12 @@ lives_ok( cmp_ok( $user->is_success, '==', 1, "add new user success" ); # add new role -lives_ok( sub { $role = $etcd->role( { name => 'myrole' } )->add; +lives_ok( + sub { + $role = $etcd->role( { name => 'myrole' } )->add; }, - "add a new role" ); + "add a new role" +); #print STDERR Dumper($role); @@ -51,8 +57,7 @@ cmp_ok( $role->is_success, '==', 1, "add new role success" ); # role get lives_ok( sub { - $role = - $etcd->role( { role => 'myrole' } )->get; + $role = $etcd->role( { role => 'myrole' } )->get; }, "get role" ); @@ -63,7 +68,8 @@ cmp_ok( $role->is_success, '==', 1, "get role success" ); lives_ok( sub { $role = - $etcd->role_perm( { name => 'myrole', key => 'foo', permType =>'READ' } )->grant; + $etcd->role_perm( + { name => 'myrole', key => 'foo', permType => 'READ' } )->grant; }, "role_perm grant" ); @@ -88,20 +94,19 @@ cmp_ok( $role->is_success, '==', 1, "grant role success" ); # list role lives_ok( sub { - $role = - $etcd->role->list; + $role = $etcd->role->list; }, "list role" ); cmp_ok( $role->is_success, '==', 1, "list role success" ); + #print STDERR Dumper($role); # revoke role lives_ok( sub { - $role = - $etcd->role_perm( { role => 'myrole', key => 'foo' } )->revoke; + $role = $etcd->role_perm( { role => 'myrole', key => 'foo' } )->revoke; }, "role_perm revoke" ); @@ -123,15 +128,12 @@ cmp_ok( $user->is_success, '==', 1, "revoke role success" ); lives_ok( sub { $user = $etcd->role( { role => 'myrole' } )->delete; }, "delete role" ); - cmp_ok( $user->is_success, '==', 1, "role delete success" ); - # delete user lives_ok( sub { $user = $etcd->user( { name => 'samba' } )->delete; }, "deleted user" ); - #print STDERR Dumper($user); cmp_ok( $user->is_success, '==', 1, "delete user success" ); diff --git a/t/06-watch.t b/t/06-watch.t index 9ec82d6..71e2442 100644 --- a/t/06-watch.t +++ b/t/06-watch.t @@ -6,31 +6,42 @@ use Net::Etcd; use Test::More; use Test::Exception; use Data::Dumper; +use Cwd; my $config; +my $dir = getcwd; -if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT}) { - $config->{host} = $ENV{ETCD_TEST_HOST}; - $config->{port} = $ENV{ETCD_TEST_PORT}; - $config->{cacert} = $ENV{ETCD_TEST_CAPATH} if $ENV{ETCD_TEST_CAPATH}; +if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT} ) { + $config->{host} = $ENV{ETCD_TEST_HOST}; + $config->{port} = $ENV{ETCD_TEST_PORT}; + $config->{ca_file} = $ENV{ETCD_CLIENT_CA_FILE} || "$dir/t/tls/ca.pem"; + $config->{key_file} = $ENV{ETCD_CLIENT_KEY_FILE} || "$dir/t/tls/client-key.pem"; + $config->{cert_file} = $ENV{ETCD_CLIENT_CERT_FILE} || "$dir/t/tls/client.pem"; + $config->{ssl} = 1; plan tests => 8; } else { - plan skip_all => "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; + plan skip_all => + "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; } -my ($watch,$key); -my $etcd = Net::Etcd->new( $config ); +my ( $watch, $key ); +my $etcd = Net::Etcd->new($config); our @events; + # create watch with callback and store events lives_ok( sub { - $watch = $etcd->watch( { key => 'foo'}, sub { - my ($result) = @_; - push @events, $result; - #print STDERR Dumper(undef, $result); - })->create; + $watch = $etcd->watch( + { key => 'foo' }, + sub { + my ($result) = @_; + push @events, $result; + + #print STDERR Dumper(undef, $result); + } + )->create; }, "watch create" ); @@ -48,21 +59,24 @@ cmp_ok( $key->is_success, '==', 1, "kv put success" ); # get range lives_ok( sub { - $key = $etcd->range( { key => 'foo' } ) + $key = $etcd->range( { key => 'foo' } ); }, "kv range" ); cmp_ok( $key->is_success, '==', 1, "kv range success" ); + #print STDERR Dumper($key); -cmp_ok( scalar @events, '==', 2, "number of async events stored. (create_watch, create key)" ); +cmp_ok( scalar @events, + '==', 2, "number of async events stored. (create_watch, create key)" ); + #print STDERR 'events ' . Dumper(@events); # delete range lives_ok( sub { - $key = $etcd->deleterange( { key => 'foo' } ) + $key = $etcd->deleterange( { key => 'foo' } ); }, "kv range_delete" ); diff --git a/t/07-member.t b/t/07-member.t index 6d4d6b3..18848a5 100644 --- a/t/07-member.t +++ b/t/07-member.t @@ -6,22 +6,27 @@ use Net::Etcd; use Test::More; use Test::Exception; use Data::Dumper; +use Cwd; my $config; - -if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT}) { - - $config->{host} = $ENV{ETCD_TEST_HOST}; - $config->{port} = $ENV{ETCD_TEST_PORT}; - $config->{cacert} = $ENV{ETCD_TEST_CAPATH} if $ENV{ETCD_TEST_CAPATH}; +my $dir = getcwd; + +if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT} ) { + $config->{host} = $ENV{ETCD_TEST_HOST}; + $config->{port} = $ENV{ETCD_TEST_PORT}; + $config->{ca_file} = $ENV{ETCD_CA_FILE} || "$dir/t/tls/ca.pem"; + $config->{key_file} = $ENV{ETCD_KEY_FILE} || "$dir/t/tls/client-key.pem"; + $config->{cert_file} = $ENV{ETCD_CERT_FILE} || "$dir/t/tls/client.pem"; + $config->{ssl} = 1; plan tests => 2; } else { - plan skip_all => "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; + plan skip_all => + "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; } my $member; -my $etcd = Net::Etcd->new( $config ); +my $etcd = Net::Etcd->new($config); # snapshot lives_ok( diff --git a/t/99-auth.t b/t/99-auth.t index 03dede2..bd952ca 100644 --- a/t/99-auth.t +++ b/t/99-auth.t @@ -7,30 +7,35 @@ use Net::Etcd; use Test::More; use Test::Exception; use Data::Dumper; +use Cwd; my $config; - -if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT}) { - $config->{host} = $ENV{ETCD_TEST_HOST}; - $config->{port} = $ENV{ETCD_TEST_PORT}; - $config->{cacert} = $ENV{ETCD_TEST_CAPATH} if $ENV{ETCD_TEST_CAPATH}; - $config->{name} = 'root'; - $config->{password} = 'toor'; +my $dir = getcwd; + +if ( $ENV{ETCD_TEST_HOST} and $ENV{ETCD_TEST_PORT} ) { + $config->{name} = 'root'; + $config->{password} = 'toor'; + $config->{host} = $ENV{ETCD_TEST_HOST}; + $config->{port} = $ENV{ETCD_TEST_PORT}; + $config->{ca_file} = $ENV{ETCD_CLIENT_CA_FILE} || "$dir/t/tls/ca.pem"; + $config->{key_file} = $ENV{ETCD_CLIENT_KEY_FILE} || "$dir/t/tls/client-key.pem"; + $config->{cert_file} = $ENV{ETCD_CLIENT_CERT_FILE} || "$dir/t/tls/client.pem"; + $config->{ssl} = 1; plan tests => 8; } else { - plan skip_all => "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; + plan skip_all => + "Please set environment variable ETCD_TEST_HOST and ETCD_TEST_PORT."; } -my $etcd = Net::Etcd->new( $config ); +my $etcd = Net::Etcd->new($config); -my ($user, $role, $auth); +my ( $user, $role, $auth ); # add user lives_ok( sub { - $user = - $etcd->user( { name => 'root', password => 'toor' } )->add; + $user = $etcd->user( { name => 'root', password => 'toor' } )->add; }, "add a new user" ); @@ -38,17 +43,19 @@ lives_ok( #print STDERR Dumper($user); # add new role -lives_ok( sub { $role = $etcd->role( { name => 'root' } )->add; +lives_ok( + sub { + $role = $etcd->role( { name => 'root' } )->add; }, - "add a new role" ); + "add a new role" +); #print STDERR Dumper($role); # grant role lives_ok( sub { - $role = - $etcd->user_role( { user => 'root', role => 'root' } )->grant; + $role = $etcd->user_role( { user => 'root', role => 'root' } )->grant; }, "grant role" ); @@ -60,8 +67,7 @@ cmp_ok( $role->is_success, '==', 1, "grant role success" ); # enable auth lives_ok( sub { - $auth = - $etcd->auth()->enable; + $auth = $etcd->auth()->enable; }, "enable auth" ); @@ -71,9 +77,8 @@ cmp_ok( $auth->is_success, '==', 1, "enable auth" ); # disable auth lives_ok( sub { - $auth = - $etcd->auth()->disable; - }, + $auth = $etcd->auth()->disable; + }, "disable auth" ); diff --git a/t/tls/etcd1-key.pem b/t/tls/etcd1-key.pem new file mode 100644 index 0000000..edff5b4 --- /dev/null +++ b/t/tls/etcd1-key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIOi+929i/S2lgUtYa1SEC8snfVbqUlsUDNdShuHI4JW9oAoGCCqGSM49 +AwEHoUQDQgAEdemjADgmj5SmmdtgfiA1nEaDM/2Ghi93A5/UysW1ToY+UsNoM/eo +cDMj8c6IdQ2D8BLKrwQttToxja1yDd8qaA== +-----END EC PRIVATE KEY----- diff --git a/t/tls/etcd1.csr b/t/tls/etcd1.csr new file mode 100644 index 0000000..b603d8c --- /dev/null +++ b/t/tls/etcd1.csr @@ -0,0 +1,9 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIBHTCBxAIBADA/MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQmluZ2hhbXRvbjEL +MAkGA1UEBxMCTlkxDjAMBgNVBAMTBWV0Y2QxMFkwEwYHKoZIzj0CAQYIKoZIzj0D +AQcDQgAEdemjADgmj5SmmdtgfiA1nEaDM/2Ghi93A5/UysW1ToY+UsNoM/eocDMj +8c6IdQ2D8BLKrwQttToxja1yDd8qaKAjMCEGCSqGSIb3DQEJDjEUMBIwEAYDVR0R +BAkwB4IFZXRjZDEwCgYIKoZIzj0EAwIDSAAwRQIgNrplAe+W2de+oa4w2Yvq1y/4 +D6urzXtJrw8CtJQQYXYCIQChSg5NW0lXHxStOQJMnIl1tgqVsHg5Tb87+ZecgyQX +uw== +-----END CERTIFICATE REQUEST----- diff --git a/t/tls/etcd1.json b/t/tls/etcd1.json new file mode 100644 index 0000000..4edd3b3 --- /dev/null +++ b/t/tls/etcd1.json @@ -0,0 +1,17 @@ +{ + "CN": "etcd1", + "hosts": [ + "etcd1" + ], + "key": { + "algo": "ecdsa", + "size": 256 + }, + "names": [ + { + "C": "US", + "L": "NY", + "ST": "Binghamton" + } + ] +} diff --git a/t/tls/etcd1.pem b/t/tls/etcd1.pem new file mode 100644 index 0000000..bb9e796 --- /dev/null +++ b/t/tls/etcd1.pem @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIIC9zCCAd+gAwIBAgIUbHYWojaWDE7d+u3T0UfrSPIjlcMwDQYJKoZIhvcNAQEL +BQAwYjELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkJpbmdoYW10b24xCzAJBgNVBAcT +Ak5ZMRIwEAYDVQQKEwlOZXQ6OkV0Y2QxHTAbBgNVBAMTFE5ldDo6RXRjZCB0ZXN0 +aW5nIENBMB4XDTE4MDQxNTE5MDQwMFoXDTIzMDQxNDE5MDQwMFowPzELMAkGA1UE +BhMCVVMxEzARBgNVBAgTCkJpbmdoYW10b24xCzAJBgNVBAcTAk5ZMQ4wDAYDVQQD +EwVldGNkMTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABHXpowA4Jo+UppnbYH4g +NZxGgzP9hoYvdwOf1MrFtU6GPlLDaDP3qHAzI/HOiHUNg/ASyq8ELbU6MY2tcg3f +KmijgZIwgY8wDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggr +BgEFBQcDAjAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBQkf/+GndaZ9iAkeej9v4Ox +mnO2DTAfBgNVHSMEGDAWgBRYy+Aa9gq2zPICLJIzW4gnigHhXjAQBgNVHREECTAH +ggVldGNkMTANBgkqhkiG9w0BAQsFAAOCAQEAiBHsgWc/0xEiPq4uSVF5Je93OoZy +16jZHETwcRriVr0Bk6u2OKX9j7RW1POO9YtJxaYHxM2c/x0mv8mbbFpbZ7lomAer +49R+0wI4LY/nzL8ZPVT07HFBiBuq8D1W5LZYJv0aOmtM73LzcF+M7E6bLm1gWVLB +fTuOq8FtneWBbStEbker/+6rrJDkhMlBbamQaYoyUWcaFmSe6sV4CpofGkOcKgnM +/M93d+rwegQUMZeJDBcnvcyYGmyWacy0C8PlDfynQ7qMnIPaYb5aWtItEoS1CgyQ +Ngr5mQw+hDbltOaHDKbzSZmowDnARsFYwPFHVIk2dLN6G3KMKF+Af/ytzg== +-----END CERTIFICATE----- diff --git a/t/tls/server-key.pem b/t/tls/server-key.pem index a9f56dc..3e02156 100644 --- a/t/tls/server-key.pem +++ b/t/tls/server-key.pem @@ -1,5 +1,5 @@ -----BEGIN EC PRIVATE KEY----- -MHcCAQEEIGstOK8LLiIHXVbppsAkwLSIbLfRJb93r2Elz+NkIgv1oAoGCCqGSM49 -AwEHoUQDQgAESTNwLWRxMXRXiiLNiDBVqjx/qitMERWIancMn1JVRYOKAUAzkT5Y -WgcUkXU0BVCioB/v4R8p8eR6bxfOHr0W3A== +MHcCAQEEILGdiE5Sz5hRdf9ihzmhjEqRImEpmts1/jTylQO/UAlvoAoGCCqGSM49 +AwEHoUQDQgAERLjPe7mhN582OdvFUQ47LND26EfvGRvjHFC1jU8hlTB6OqFmAglf +Lv39whYuBGCoDcuOAAa7l0OhznbPGZ/b7w== -----END EC PRIVATE KEY----- diff --git a/t/tls/server.csr b/t/tls/server.csr index 41f4d11..cd0f50e 100644 --- a/t/tls/server.csr +++ b/t/tls/server.csr @@ -1,9 +1,9 @@ -----BEGIN CERTIFICATE REQUEST----- -MIIBMDCB1wIBADBBMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQmluZ2hhbXRvbjEL +MIIBQjCB6QIBADBBMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQmluZ2hhbXRvbjEL MAkGA1UEBxMCTlkxEDAOBgNVBAMTB3RyYXZpczEwWTATBgcqhkjOPQIBBggqhkjO -PQMBBwNCAARJM3AtZHExdFeKIs2IMFWqPH+qK0wRFYhqdwyfUlVFg4oBQDORPlha -BxSRdTQFUKKgH+/hHynx5HpvF84evRbcoDQwMgYJKoZIhvcNAQkOMSUwIzAhBgNV -HREEGjAYgg10cmF2aXMxLmxvY2Fsggd0cmF2aXMxMAoGCCqGSM49BAMCA0gAMEUC -IBrnU43ZQupF66TBY1t5rTy5mahaXtuMO3wM3wuCBKxxAiEA7QaD4EvSwPN4gUeU -ZQO8AxeEFwGUs+tUgeCXuvLoK4I= +PQMBBwNCAAREuM97uaE3nzY528VRDjss0PboR+8ZG+McULWNTyGVMHo6oWYCCV8u +/f3CFi4EYKgNy44ABruXQ6HOds8Zn9vvoEYwRAYJKoZIhvcNAQkOMTcwNTAzBgNV +HREELDAqgg10cmF2aXMxLmxvY2Fsggd0cmF2aXMxgglsb2NhbGhvc3SCBWV0Y2Qx +MAoGCCqGSM49BAMCA0gAMEUCID2EGxYo+GkVtlyybhFpVNm0jDyXou5bP3GRSl+a +VbxZAiEAo7yjFmchvLI1yXHUUtxo8+PY7QvTFakj7hBp92Ct2fs= -----END CERTIFICATE REQUEST----- diff --git a/t/tls/server.json b/t/tls/server.json index c9cec8b..a799dd7 100644 --- a/t/tls/server.json +++ b/t/tls/server.json @@ -2,7 +2,9 @@ "CN": "travis1", "hosts": [ "travis1.local", - "travis1" + "travis1", + "localhost", + "etcd1" ], "key": { "algo": "ecdsa", diff --git a/t/tls/server.pem b/t/tls/server.pem index 777d7b7..7a8d434 100644 --- a/t/tls/server.pem +++ b/t/tls/server.pem @@ -1,19 +1,19 @@ -----BEGIN CERTIFICATE----- -MIIDADCCAeigAwIBAgIUYTLxBXsv3Jk0/ChXIHV6i2FjFmQwDQYJKoZIhvcNAQEL +MIIDEjCCAfqgAwIBAgIUT+MWn7Io93N9PiSa8Urmlmtqcr4wDQYJKoZIhvcNAQEL BQAwYjELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkJpbmdoYW10b24xCzAJBgNVBAcT Ak5ZMRIwEAYDVQQKEwlOZXQ6OkV0Y2QxHTAbBgNVBAMTFE5ldDo6RXRjZCB0ZXN0 -aW5nIENBMB4XDTE3MTEyNDEzNTQwMFoXDTIyMTEyMzEzNTQwMFowQTELMAkGA1UE +aW5nIENBMB4XDTE4MDQxNTE1MDMwMFoXDTIzMDQxNDE1MDMwMFowQTELMAkGA1UE BhMCVVMxEzARBgNVBAgTCkJpbmdoYW10b24xCzAJBgNVBAcTAk5ZMRAwDgYDVQQD -Ewd0cmF2aXMxMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESTNwLWRxMXRXiiLN -iDBVqjx/qitMERWIancMn1JVRYOKAUAzkT5YWgcUkXU0BVCioB/v4R8p8eR6bxfO -Hr0W3KOBmTCBljAOBgNVHQ8BAf8EBAMCBaAwEwYDVR0lBAwwCgYIKwYBBQUHAwEw -DAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUeCmle4VmjG3In771lZDggy1RXlEwHwYD -VR0jBBgwFoAUWMvgGvYKtszyAiySM1uIJ4oB4V4wIQYDVR0RBBowGIINdHJhdmlz -MS5sb2NhbIIHdHJhdmlzMTANBgkqhkiG9w0BAQsFAAOCAQEAN0se4PFKHE8R87qc -8FpGvFmsk/XO/0uuPp1D8LoV09Ss/E3UCEa7muMT+DI7PbBcme2rbVzvsH3Uj8XE -/TdDfo3pgP+hfTZMDHpTIfr5z4he5ABVV6Ab8YsYYgv7Dk6pv2POX85YqAxe3aKE -EfmPkSA3o6bOp/OOUr7rordJe0849B3yPWAi/IRU6STsemn0PFpC7cu42r2fMoh0 -MLUT0pZYTst4j3gP9eLy3osux95HqhcN5/jUwv+kEUb89mQHNIMtx4725MZ99IXb -A13IlV127pweHFrFwKjJnWyOCRc3kuXSBEKM3j1NzalHvVwPNvOLMSE0QahOoKXI -eUAdpQ== +Ewd0cmF2aXMxMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAERLjPe7mhN582OdvF +UQ47LND26EfvGRvjHFC1jU8hlTB6OqFmAglfLv39whYuBGCoDcuOAAa7l0OhznbP +GZ/b76OBqzCBqDAOBgNVHQ8BAf8EBAMCBaAwEwYDVR0lBAwwCgYIKwYBBQUHAwEw +DAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUWZrjuwa0JKouNAZf/006YEN1KQcwHwYD +VR0jBBgwFoAUWMvgGvYKtszyAiySM1uIJ4oB4V4wMwYDVR0RBCwwKoINdHJhdmlz +MS5sb2NhbIIHdHJhdmlzMYIJbG9jYWxob3N0ggVldGNkMTANBgkqhkiG9w0BAQsF +AAOCAQEAeXskgC53UZ51tufB86680vehW5hxt+REJFFIGgfmO2/jehSQ0TvpZsRX +t0noK3uCp/M4IuoYKI/1/8F29It2jEne9ADK5fOEfVkFSYbKnYPD5JuSXirMMYrE +absiphHJKVYR9uRDoq5c8/+a1cNyLJ29q8EME4RwTSwBcvTvdGBk+vcvjuPIEoVE +OzlTksai19NsSHY8Nu3GYGWoYute8PXnN4MZ+E2Rx9l/9WzNNsc2q2BAmwqE/TM2 +aEql4YOqaSZ4R/s6cqStoLQQVYBaltr7r8B47gdBs+yYDQp55jbUuJO3tZ0NYT0u +r1tbkquupBGCQQ0+jjAwOORBYtweIw== -----END CERTIFICATE-----