diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..da657d1 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +SESSION_VALIDATOR_KEYID='' +SESSION_VALIDATOR_URL='' +KEY_POOL='[{"keyId":"","secret":"","acceptOnly":0}]' diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 7f0b887..d0507c3 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -7,10 +7,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-versions: ['2.6', '2.7', '3.0'] + ruby-versions: ['2.6', '2.7', '3.0', '3.2'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-versions }} @@ -28,4 +28,4 @@ jobs: gem build *.gemspec gem push *.gem env: - GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}" \ No newline at end of file + GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}" diff --git a/.gitignore b/.gitignore index 83f5868..bacc85b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.gem Gemfile.lock .ruby-version +.env diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..67dd23b --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: test sh + +test: + docker compose run --rm app bash -c "bundle install && rspec" + +sh: + docker compose run --rm app bash -c "bundle install && bash" diff --git a/README.md b/README.md index 1f2db72..d751d67 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# session-validator-client-ruby ![Build status](https://travis-ci.org/emartech/session-validator-client-ruby.svg?branch=master) +# Session Validator Client Ruby ![Build Status](https://github.com/emartech/session-validator-client-ruby/actions/workflows/ruby.yml/badge.svg) Ruby client for Emarsys session validator service. @@ -10,35 +10,38 @@ gem install session-validator-client ## Usage -Setup the following environment variables: - -* `KEY_POOL` -* `SESSION_VALIDATOR_KEYID` -* `SESSION_VALIDATOR_URL` - -### Validating a single Msid -`valid?(msid)` returns `true` if `msid` is valid +Copy `.env.example` to `.env` and set the necessary values for usage in your service. +### Create client ```ruby require "session_validator" client = SessionValidator::Client.new -client.valid?("staging_int_5ad5f96f307cf9.61063404") ``` -### Batch validating multiple MSIDS -`filter_invalid(msids)` returns an array of the invalid MSIDS. +### Requests without Escher +For mTLS on GAP. ```ruby require "session_validator" -client = SessionValidator::Client.new +client = SessionValidator::Client.new(use_escher: false) +``` + +### Validating a single MSID +```ruby +client.valid?("staging_int_5ad5f96f307cf9.61063404") +``` + +### Batch validating multiple MSIDs +Returns an array of the invalid MSIDs. +```ruby client.filter_invalid(["staging_int_5ad5f96f307cf9.61063404", "staging_int_5ad5f96f307cf9.61063405"]) ``` -## Running tests +## Local development +### Running tests ```bash -$ bundle install -$ rspec +make test ``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c84802d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +services: + app: + image: ruby:3.2.5 + working_dir: /home/app/src + volumes: + - .:/home/app/src diff --git a/session-validator-client.gemspec b/session-validator-client.gemspec index 4973b2f..e47a23d 100644 --- a/session-validator-client.gemspec +++ b/session-validator-client.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "session-validator-client" - s.version = "5.1.0" + s.version = "5.1.1" s.summary = "Ruby client for Emarsys session validator service" s.authors = ["Emarsys Technologies Ltd."] s.email = "security@emarsys.com"