Skip to content

Commit

Permalink
Support ruby 3.0.2 (#197)
Browse files Browse the repository at this point in the history
* Resolve compatability with ruby-3.0.2
  • Loading branch information
semyon-estrin authored Dec 9, 2021
1 parent 7cc88aa commit 4127bf7
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Upgrade and set ruby-3.0.2 as default.
[cyberark/conjur-api-ruby#197](https://github.com/cyberark/conjur-api-ruby/pull/197)

## [5.3.5] - 2021-05-04

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

#ruby=ruby-2.7
#ruby=ruby-3.0
#ruby-gemset=conjur-api

# Specify your gem's dependencies in conjur-api.gemspec
Expand Down
22 changes: 19 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pipeline {
}
}

stage('Test 2.5') {
stage('Test Ruby 2.5') {
environment {
RUBY_VERSION = '2.5'
}
Expand All @@ -43,7 +43,7 @@ pipeline {
}
}

stage('Test 2.6') {
stage('Test Ruby 2.6') {
environment {
RUBY_VERSION = '2.6'
}
Expand All @@ -60,7 +60,7 @@ pipeline {
}
}

stage('Test 2.7') {
stage('Test Ruby 2.7') {
environment {
RUBY_VERSION = '2.7'
}
Expand All @@ -77,6 +77,22 @@ pipeline {
}
}

stage('Test Ruby 3.0') {
environment {
RUBY_VERSION = '3.0'
}
steps {
sh("./test.sh")
}
post {
always {
junit 'spec/reports/*.xml'
junit 'features/reports/*.xml'
junit 'features_v4/reports/*.xml'
}
}
}

stage('Submit Coverage Report'){
steps{
sh 'ci/submit-coverage'
Expand Down
3 changes: 2 additions & 1 deletion conjur-api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ Gem::Specification.new do |gem|
gem.executables -= %w{parse-changelog.sh}

gem.add_dependency 'rest-client'
gem.add_dependency 'activesupport'
gem.add_dependency 'activesupport', '>= 4.2'
gem.add_dependency 'addressable', '~> 2.8.0'

gem.add_development_dependency 'rake', '>= 12.3.3'
gem.add_development_dependency 'rspec', '~> 3'
Expand Down
5 changes: 2 additions & 3 deletions lib/conjur/escape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ def path_or_query_escape(str)
return "false" unless str
str = str.id if str.respond_to?(:id)
# Leave colons and forward slashes alone
require 'uri'
pattern = URI::PATTERN::UNRESERVED + ":\\/@"
URI.escape(str.to_s, Regexp.new("[^#{pattern}]"))
require 'addressable/uri'
Addressable::URI.encode(str.to_s)
end
end

Expand Down
11 changes: 4 additions & 7 deletions spec/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,26 @@
describe Conjur::API do

let(:account) { 'api-spec-acount' }
let(:remote_ip) { nil }
before { allow(Conjur.configuration).to receive_messages account: account }

shared_context "logged in", logged_in: true do
let(:login) { "bob" }
let(:token) { { 'data' => login, 'timestamp' => Time.now.to_s } }
let(:remote_ip) { nil }
let(:api_args) { [ token, { remote_ip: remote_ip } ] }
subject(:api) { Conjur::API.new_from_token(*api_args) }
subject(:api) { Conjur::API.new_from_token(token, remote_ip: remote_ip) }
end

shared_context "logged in with an API key", logged_in: :api_key do
include_context "logged in"
let(:api_key) { "theapikey" }
let(:api_args) { [ login, api_key, { remote_ip: remote_ip, account: account } ] }
subject(:api) { Conjur::API.new_from_key(*api_args) }
subject(:api) { Conjur::API.new_from_key(login, api_key, account: account ,remote_ip: remote_ip) }
end

shared_context "logged in with a token file", logged_in: :token_file do
include FakeFS::SpecHelpers
include_context "logged in"
let(:token_file) { "token_file" }
let(:api_args) { [ token_file, { remote_ip: remote_ip } ] }
subject(:api) { Conjur::API.new_from_token_file(*api_args) }
subject(:api) { Conjur::API.new_from_token_file(token_file, remote_ip: remote_ip) }
end

def time_travel delta
Expand Down
6 changes: 5 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e

: "${RUBY_VERSION=2.7}"
: "${RUBY_VERSION=3.0}"
# My local RUBY_VERSION is set to ruby-#.#.# so this allows running locally.
RUBY_VERSION="$(cut -d '-' -f 2 <<< "$RUBY_VERSION")"

Expand All @@ -15,6 +15,10 @@ trap finish EXIT


function main() {
if ! docker info >/dev/null 2>&1; then
echo "Docker does not seem to be running, run it first and retry"
exit 1
fi
# Generate reports folders locally
mkdir -p spec/reports features/reports features_v4/reports

Expand Down

0 comments on commit 4127bf7

Please sign in to comment.