Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Commit

Permalink
SDK-273 v1.2.0 (#3)
Browse files Browse the repository at this point in the history
* [SDK-273]: Update strategy and bump version

* [SDK-273]: Update strategy and bump version

* [SDK-273]: Add minor tweaks
  • Loading branch information
zarembas authored Mar 15, 2018
1 parent 0f10bca commit 5944940
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 86 deletions.
26 changes: 16 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# Change Log
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
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).

## 1.1.3 - 2017-11-01
## [1.2.0] - 2018-03-09
### Added
- `age_verified` returns a boolean value of the age validation

### Changed
- Moved the profile attributes in the response Hash from `extra` to `info`. Please check [README.md](README.md#upgrading-from-version-11) for details.

## [1.1.3] - 2017-11-01
### Added
- `base64_selfie_uri` value

## 1.1.2 - 2017-10-18
## [1.1.2] - 2017-10-18

## 1.1.1 - 2017-09-13
## [1.1.1] - 2017-09-13
### Changed
- Switched from proprietary to MIT license

Expand All @@ -21,8 +27,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `simplecov` `~> 0.15`
- `webmock` `~> 3.0`

## 1.1.0 - 2017-04-11
Updates dependencies to the latest versions and aligns extra fields naming conventions with the Yoti attributes.
## [1.1.0] - 2017-04-11
Updated dependencies to the latest versions and aligns extra fields naming conventions with the Yoti attributes.

### Added
- `email_address` field
Expand All @@ -40,10 +46,10 @@ Updates dependencies to the latest versions and aligns extra fields naming conve
- `simplecov` `~> 0.14`
- `webmock` `~> 2.3`

## 1.0.1 - 2016-11-28
## [1.0.1] - 2016-11-28
### Added
- Yoti proprietary license

## 1.0.0 - 2016-11-25
## [1.0.0] - 2016-11-25
### Added
- This is an initial public release.
53 changes: 37 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ gem 'omniauth-yoti'
And then execute:

```shell
$ bundle
bundle
```

Or install it yourself as:

```shell
$ gem install omniauth-yoti
gem install omniauth-yoti
```

## Configuration
Expand Down Expand Up @@ -63,21 +63,42 @@ A call to `/auth/yoti/callback` will open the Yoti authentication page, and afte
"provider" => "yoti",
"uid" => "mHvpV4...",
"info" => {
"name" => "mHvpV4Mm+yMb...",
"base64_selfie_uri" => "data:image/jpeg;base64,/9j/2wCEAAMCAg..."
},
"name" => "John Doe",
"selfie" => "jpeg image data file",
"full_name" => "John Doe",
"given_names" => "John",
"family_name" => "Doe",
"phone_number" => "07474747474",
"email_address" => "[email protected]",
"date_of_birth" => "1989-11-09",
"postal_address" => "Fountain House\n130 Fenchurch St\nLONDON\nEC3M 5DJ",
"gender" => "MALE",
"nationality" => "GBR"
"base64_selfie_uri" => "data:image/jpeg;base64,/9j/2wCEAAMCAg..."
"age_verified" => true
},
"credentials" => {},
"extra" => {
"selfie" => "jpeg image file",
"given_names" => "Given Name",
"family_name" => "Family Name",
"phone_number" => "07474747474",
"email_address" => "[email protected]",
"date_of_birth" => nil,
"postal_address" => nil,
"gender" => 'MALE',
"nationality" => nil
}
{ "raw_info" =>
{
"selfie" => "jpeg image data file",
"full_name" => "John Doe",
"given_names" => "Given Name",
"family_name" => "Family Name",
"phone_number" => "07474747474",
"email_address" => "[email protected]",
"date_of_birth" => "1989-11-09",
"postal_address" => "Fountain House\n130 Fenchurch St\nLONDON\nEC3M 5DJ",
"gender" => "MALE",
"nationality" => "GBR",
"age_over:18" => true
}
}
}

```

## Upgrading from version 1.1

Most of the profile attributes that were being stored in the `extra` fields got moved to `info`.

e.g. `request.env['omniauth.auth']['extra']['given_names']` will become `request.env['omniauth.auth']['info']['given_names']`
28 changes: 21 additions & 7 deletions lib/omniauth/strategies/yoti.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,35 @@ def request_phase
end

uid { yoti_user_id }
info {{
name: yoti_user_id,
base64_selfie_uri: base64_selfie_uri
}}

def extra
@raw_info ||= {
info do
{
name: yoti_user_profile['full_name'],
selfie: yoti_user_profile['selfie'],
full_name: yoti_user_profile['full_name'],
given_names: yoti_user_profile['given_names'],
family_name: yoti_user_profile['family_name'],
phone_number: yoti_user_profile['phone_number'],
email_address: yoti_user_profile['email_address'],
date_of_birth: yoti_user_profile['date_of_birth'],
postal_address: yoti_user_profile['postal_address'],
gender: yoti_user_profile['gender'],
nationality: yoti_user_profile['nationality']
nationality: yoti_user_profile['nationality'],
base64_selfie_uri: base64_selfie_uri,
age_verified: age_verified
}
end

extra do
{
raw_info: raw_info
}
end

def raw_info
@raw_info ||= yoti_user_profile
end

private

def yoti_activity_details
Expand All @@ -53,6 +63,10 @@ def base64_selfie_uri
yoti_activity_details.base64_selfie_uri
end

def age_verified
yoti_activity_details.age_verified
end

def configure_yoti_client!
::Yoti.configure do |config|
config.client_sdk_id = options.client_options[:client_sdk_id]
Expand Down
2 changes: 1 addition & 1 deletion lib/omniauth/yoti/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Omniauth
module Yoti
VERSION = '1.1.3'.freeze
VERSION = '1.2.0'.freeze
end
end
6 changes: 2 additions & 4 deletions omniauth-yoti.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# coding: utf-8

lib = File.expand_path('../lib', __FILE__)
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'omniauth/yoti/version'

Expand All @@ -22,7 +20,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.1.9'

spec.add_dependency 'omniauth', '~> 1.6'
spec.add_dependency 'yoti', '~> 1.1.0'
spec.add_dependency 'yoti', '~> 1.2.1'

spec.add_development_dependency 'bundler', '~> 1.13'
spec.add_development_dependency 'rake', '~> 12.1'
Expand Down
7 changes: 5 additions & 2 deletions rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
TargetRubyVersion: 2.3
TargetRubyVersion: 2.1.9

Metrics/AbcSize:
Max: 20
Expand All @@ -13,6 +13,9 @@ Metrics/MethodLength:
CountComments: false
Max: 15

Metrics/BlockLength:
Enabled: false

Style/Documentation:
Enabled: false

Expand All @@ -22,5 +25,5 @@ Style/FrozenStringLiteralComment:
Style/NumericLiterals:
Enabled: false

Style/FileName:
Naming:
Enabled: false
98 changes: 53 additions & 45 deletions spec/omniauth/strategies/yoti_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,78 +46,78 @@
end

describe '#info' do
it 'returns the name value' do
expect(subject.info[:name]).to eql('Hig2yAT79cWvseSuXcIuCLa5lNkAPy70rxetUaeHlTJGmiwc/g1MWdYWYrexWvPU')
context 'when using a mock request' do
it 'returns the base64_selfie_uri value' do
selfie = File.read('spec/fixtures/selfie.txt', encoding: 'utf-8')
expect(subject.info[:base64_selfie_uri]).to eql(selfie)
end
end

it 'returns the base64_selfie_uri value' do
selfie = File.read('spec/fixtures/selfie.txt', encoding: 'utf-8')
expect(subject.info[:base64_selfie_uri]).to eql(selfie)
context 'when using a mock object' do
before do
allow(subject).to receive(:yoti_user_profile).and_return(yoti_user_profile_mock)
allow(subject).to receive(:base64_selfie_uri).and_return(base64_selfie_uri_mock)
allow(subject).to receive(:age_verified).and_return(age_verified_mock)
end

it 'returns the correct values' do
expect(subject.info[:name]).to eql('John Doe')
expect(subject.info[:selfie]).to eql('selfie.png')
expect(subject.info[:full_name]).to eql('John Doe')
expect(subject.info[:given_names]).to eql('John')
expect(subject.info[:family_name]).to eql('Doe')
expect(subject.info[:phone_number]).to eql('07474747474')
expect(subject.info[:email_address]).to eql('[email protected]')
expect(subject.info[:date_of_birth]).to eql('2000.12.12')
expect(subject.info[:postal_address]).to eql('WC2N 4JH')
expect(subject.info[:gender]).to eql('male')
expect(subject.info[:nationality]).to eql('British')
expect(subject.info[:base64_selfie_uri]).to eql('data:image/jpeg;base64,/9j/2wCEAAMCAg')
expect(subject.info[:age_verified]).to eql(true)
end
end
end

describe '#extra' do
context 'when using a mock request' do
it 'has the correct selfie' do
selfie = File.read('spec/fixtures/selfie.txt', encoding: 'utf-8')
expect('data:image/jpeg;base64,'.concat(Base64.strict_encode64(subject.extra[:selfie]))).to eql(selfie)
expect('data:image/jpeg;base64,'.concat(Base64.strict_encode64(subject.extra[:raw_info]['selfie']))).to eql(selfie)
end

it 'has the correct phone number' do
expect(subject.extra[:phone_number]).to eql('+447474747474')
expect(subject.extra[:raw_info]['phone_number']).to eql('+447474747474')
end
end

context 'when using a mock object' do
before do
allow(subject).to receive(:yoti_user_profile).and_return(raw_info_hash)
end

it 'has the correct selfie' do
expect(subject.extra[:selfie]).to eql('selfie.png')
end

it 'has the correct given names' do
expect(subject.extra[:given_names]).to eql('Given Names')
end

it 'has the correct family name' do
expect(subject.extra[:family_name]).to eql('Family Name')
allow(subject).to receive(:yoti_user_profile).and_return(yoti_user_profile_mock)
end

it 'has the correct mobile number' do
expect(subject.extra[:phone_number]).to eql('07474747474')
end

it 'has the correct email address' do
expect(subject.extra[:email_address]).to eql('[email protected]')
end

it 'has the correct date of birth' do
expect(subject.extra[:date_of_birth]).to eql('2000.12.12')
end

it 'has the correct postal address' do
expect(subject.extra[:postal_address]).to eql('WC2N 4JH')
end

it 'has the correct gender' do
expect(subject.extra[:gender]).to eql('male')
end

it 'has the correct nationality' do
expect(subject.extra[:nationality]).to eql('British')
it 'returns the correct values' do
expect(subject.extra[:raw_info]['selfie']).to eql('selfie.png')
expect(subject.extra[:raw_info]['full_name']).to eql('John Doe')
expect(subject.extra[:raw_info]['given_names']).to eql('John')
expect(subject.extra[:raw_info]['family_name']).to eql('Doe')
expect(subject.extra[:raw_info]['phone_number']).to eql('07474747474')
expect(subject.extra[:raw_info]['email_address']).to eql('[email protected]')
expect(subject.extra[:raw_info]['date_of_birth']).to eql('2000.12.12')
expect(subject.extra[:raw_info]['postal_address']).to eql('WC2N 4JH')
expect(subject.extra[:raw_info]['gender']).to eql('male')
expect(subject.extra[:raw_info]['nationality']).to eql('British')
end
end
end

private

def raw_info_hash
def yoti_user_profile_mock
{
'selfie' => 'selfie.png',
'given_names' => 'Given Names',
'family_name' => 'Family Name',
'full_name' => 'John Doe',
'given_names' => 'John',
'family_name' => 'Doe',
'phone_number' => '07474747474',
'email_address' => '[email protected]',
'date_of_birth' => '2000.12.12',
Expand All @@ -126,4 +126,12 @@ def raw_info_hash
'nationality' => 'British'
}
end

def base64_selfie_uri_mock
'data:image/jpeg;base64,/9j/2wCEAAMCAg'
end

def age_verified_mock
true
end
end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'simplecov'
SimpleCov.start
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'omniauth/yoti'
require 'webmock/rspec'

Expand Down

0 comments on commit 5944940

Please sign in to comment.