Commit b27b911

mokha <mokha@cisco.com>
2019-01-18 22:34:13
reboot
1 parent f285b32
lib/scim/shady/builders/addresses.rb
@@ -1,24 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class Addresses
-        def add(type:, street_address:, locality:, region:, postal_code:, country:, primary: false)
-          @items ||= []
-          @items.push(
-            type: type,
-            streetAddress: street_address,
-            locality: locality,
-            region: region,
-            postalCode: postal_code,
-            country: country,
-            primary: primary,
-          )
-        end
-
-        def to_h
-          { 'addresses' => @items }
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders/bulk.rb
@@ -1,19 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class Bulk
-        attr_accessor :supported
-        attr_accessor :max_operations
-        attr_accessor :max_payload_size
-
-        def to_h
-          {
-            'supported' => supported,
-            'maxOperations' => max_operations,
-            'maxPayloadSize' => max_payload_size,
-          }
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders/emails.rb
@@ -1,16 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class Emails
-        def add(email, type: :work, primary: false)
-          @items ||= []
-          @items.push(value: email, type: type, primary: primary)
-        end
-
-        def to_h
-          { 'emails' => @items }
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders/filter.rb
@@ -1,17 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class Filter
-        attr_accessor :supported
-        attr_accessor :max_results
-
-        def to_h
-          {
-            'supported' => supported,
-            'maxResults' => max_results,
-          }
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders/groups.rb
@@ -1,16 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class Groups
-        def add(id, url, display_name)
-          @items ||= []
-          @items.push(value: id, '$ref' => url, display: display_name)
-        end
-
-        def to_h
-          { 'groups' => @items }
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders/instant_messengers.rb
@@ -1,16 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class InstantMessengers
-        def add(handle, type:)
-          @items ||= []
-          @items.push(value: handle, type: type)
-        end
-
-        def to_h
-          { 'ims' => @items }
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders/metadata.rb
@@ -1,29 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class Metadata
-        attr_accessor :created_at
-        attr_accessor :updated_at
-        attr_accessor :location
-        attr_accessor :version
-
-        def initialize(resource)
-          @resource = resource
-          @created_at = @updated_at = Time.now
-        end
-
-        def to_h
-          {
-            'meta' => {
-              'resourceType' => @resource.class.name.split(/::/).last,
-              'created' => created_at.to_time.utc.iso8601,
-              'lastModified' => updated_at.to_time.utc.iso8601,
-              'location' => location,
-              'version' => version,
-            },
-          }
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders/name.rb
@@ -1,27 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class Name
-        attr_accessor :family_name
-        attr_accessor :given_name
-        attr_accessor :middle_name
-        attr_accessor :honorific_prefix
-        attr_accessor :honorific_suffix
-        attr_accessor :formatted
-
-        def to_h
-          {
-            'name' => {
-              'formatted' => formatted,
-              'familyName' => family_name,
-              'givenName' => given_name,
-              'middleName' => middle_name,
-              'honorificPrefix' => honorific_prefix,
-              'honorificSuffix' => honorific_suffix,
-            }
-          }
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders/phone_numbers.rb
@@ -1,16 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class PhoneNumbers
-        def add(phone_number, type: :work)
-          @items ||= []
-          @items.push(value: phone_number, type: type)
-        end
-
-        def to_h
-          { 'phoneNumbers' => @items }
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders/photos.rb
@@ -1,16 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class Photos
-        def add(url, type: :photo)
-          @items ||= []
-          @items.push(value: url, type: type)
-        end
-
-        def to_h
-          { 'photos' => @items }
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders/resource.rb
@@ -1,26 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class Resource
-        extend Forwardable
-        attr_accessor :id
-        def_delegators :@meta, :created_at=, :updated_at=, :location=, :version=
-
-        def initialize
-          @meta = Metadata.new(self)
-        end
-
-        def meta
-          yield @meta
-        end
-
-        def to_h
-          {
-            'schemas' => [],
-            'id' => id,
-          }.merge(@meta.to_h)
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders/service_provider_config.rb
@@ -1,87 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class ServiceProviderConfig
-        extend Forwardable
-        def_delegators :@meta, :created_at=, :updated_at=, :location=, :version=
-        def_delegators :@meta, :created_at, :updated_at, :location, :version
-        attr_accessor :documentation_uri
-        attr_accessor :patch
-        attr_accessor :change_password_supported
-        attr_accessor :sort_supported
-        attr_accessor :etag_supported
-
-        def initialize
-          @authentication_schemes = []
-          @created_at = @updated_at = Time.now
-          @meta = Metadata.new(self)
-        end
-
-        def meta
-          yield @meta
-        end
-
-        def bulk
-          @bulk = Bulk.new
-          yield @bulk
-        end
-
-        def filter
-          @filter = Filter.new
-          yield @filter
-        end
-
-        def add_authentication_scheme(type)
-          if :oauth_bearer_token == type
-            @authentication_schemes.push({
-              "name" => "OAuth Bearer Token",
-              "description" => "Authentication scheme using the OAuth Bearer Token Standard",
-              "specUri" => "http://www.rfc-editor.org/info/rfc6750",
-              "documentationUri" => "http://example.com/help/oauth.html",
-              "type" => "oauthbearertoken",
-            })
-          elsif :http_basic == type
-            @authentication_schemes.push({
-              "name" => "HTTP Basic",
-              "description" => "Authentication scheme using the HTTP Basic Standard",
-              "specUri" => "http://www.rfc-editor.org/info/rfc2617",
-              "documentationUri" => "http://example.com/help/httpBasic.html",
-              "type" => "httpbasic",
-            })
-          end
-        end
-
-        def build
-          Scim::Shady::ServiceProviderConfig.new(to_json)
-        end
-
-        def to_json
-          JSON.generate(to_h)
-        end
-
-        def to_h
-          {
-            'schemas' => [Schemas::SERVICE_PROVIDER_CONFIG],
-            'documentationUri' => documentation_uri,
-            'patch' => { "supported" => patch },
-            'bulk' => @bulk.to_h,
-            'filter' => @filter.to_h,
-            'changePassword' => {
-              'supported' => change_password_supported,
-            },
-            'sort' => {
-              'supported' => sort_supported,
-            },
-            'etag' => {
-              'supported' => etag_supported,
-            },
-            'authenticationSchemes' => @authentication_schemes.each_with_index.map do |scheme, index|
-              scheme['primary'] = true if index.zero?
-              scheme
-            end
-          }.merge(@meta.to_h)
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders/user.rb
@@ -1,96 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class User < Resource
-        attr_accessor :external_id
-        attr_accessor :username
-        attr_accessor :display_name
-        attr_accessor :nick_name
-        attr_accessor :profile_url
-        attr_accessor :user_type
-        attr_accessor :title
-        attr_accessor :preferred_language
-        attr_accessor :locale
-        attr_accessor :timezone
-        attr_accessor :active
-
-        def initialize
-          @name = Name.new
-          @emails = Emails.new
-          @addresses = Addresses.new
-          @phone_numbers = PhoneNumbers.new
-          @instant_messengers = InstantMessengers.new
-          @photos = Photos.new
-          @groups = Groups.new
-          @x509_certificates = X509Certificates.new
-          super
-        end
-
-        def name
-          yield @name
-        end
-
-        def emails
-          yield @emails
-        end
-
-        def addresses
-          yield @addresses
-        end
-
-        def phone_numbers
-          yield @phone_numbers
-        end
-
-        def instant_messengers
-          yield @instant_messengers
-        end
-
-        def photos
-          yield @photos
-        end
-
-        def groups
-          yield @groups
-        end
-
-        def x509_certificates
-          yield @x509_certificates
-        end
-
-        def build
-          Scim::Shady::User.new(to_json)
-        end
-
-        def to_json
-          JSON.generate(to_h)
-        end
-
-        def to_h
-          super.merge({
-            'schemas' => [Schemas::USER],
-            'externalId' => external_id,
-            'userName' => username,
-            'displayName' => display_name,
-            'nickName' => nick_name,
-            'profile_url' => profile_url,
-            'userType' => user_type,
-            'title' => title,
-            'preferredLanguage' => preferred_language,
-            'locale' => locale,
-            'timezone' => timezone,
-            'active' => active,
-          })
-            .merge(@name.to_h)
-            .merge(@emails.to_h)
-            .merge(@addresses.to_h)
-            .merge(@phone_numbers.to_h)
-            .merge(@instant_messengers.to_h)
-            .merge(@photos.to_h)
-            .merge(@groups.to_h)
-            .merge(@x509_certificates.to_h)
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders/x509_certificates.rb
@@ -1,16 +0,0 @@
-module Scim
-  module Shady
-    module Builders
-      class X509Certificates
-        def add(certificate)
-          @items ||= []
-          @items.push(value: certificate.to_pem.gsub(/-----BEGIN CERTIFICATE-----/, '').gsub(/-----END CERTIFICATE-----/, ''))
-        end
-
-        def to_h
-          { 'x509Certificates' => @items }
-        end
-      end
-    end
-  end
-end
lib/scim/shady/address.rb
@@ -1,41 +0,0 @@
-module Scim
-  module Shady
-    class Address
-      def initialize(hash)
-        @hash = hash
-      end
-
-      def street_address
-        to_h['streetAddress']
-      end
-
-      def locality
-        to_h['locality']
-      end
-
-      def region
-        to_h['region']
-      end
-
-      def postal_code
-        to_h['postalCode']
-      end
-
-      def country
-        to_h['country']
-      end
-
-      def formatted
-        "#{street_address}\n#{locality}, #{region} #{postal_code} #{country}"
-      end
-
-      def primary?
-        to_h['primary']
-      end
-
-      def to_h
-        @hash
-      end
-    end
-  end
-end
lib/scim/shady/buildable.rb
@@ -1,21 +0,0 @@
-module Scim
-  module Shady
-    module Buildable
-      extend ActiveSupport::Concern
-
-      class_methods do
-        def build
-          builder do |builder|
-            yield builder if block_given?
-          end.build
-        end
-
-        def builder
-          builder = builder_class.new
-          yield builder if block_given?
-          builder
-        end
-      end
-    end
-  end
-end
lib/scim/shady/builders.rb
@@ -1,14 +0,0 @@
-require "scim/shady/builders/addresses"
-require "scim/shady/builders/bulk"
-require "scim/shady/builders/emails"
-require "scim/shady/builders/filter"
-require "scim/shady/builders/groups"
-require "scim/shady/builders/instant_messengers"
-require "scim/shady/builders/metadata"
-require "scim/shady/builders/name"
-require "scim/shady/builders/phone_numbers"
-require "scim/shady/builders/photos"
-require "scim/shady/builders/resource"
-require "scim/shady/builders/service_provider_config"
-require "scim/shady/builders/user"
-require "scim/shady/builders/x509_certificates"
lib/scim/shady/group.rb
@@ -1,25 +0,0 @@
-module Scim
-  module Shady
-    class Group
-      def initialize(hash)
-        @hash = hash
-      end
-
-      def value
-        to_h['value']
-      end
-
-      def reference
-        to_h['$ref']
-      end
-
-      def display
-        to_h['display']
-      end
-
-      def to_h
-        @hash
-      end
-    end
-  end
-end
lib/scim/shady/instant_messenger.rb
@@ -1,21 +0,0 @@
-module Scim
-  module Shady
-    class InstantMessenger
-      def initialize(hash)
-        @hash = hash
-      end
-
-      def value
-        to_h['value']
-      end
-
-      def type
-        to_h['type']
-      end
-
-      def to_h
-        @hash
-      end
-    end
-  end
-end
lib/scim/shady/metadata.rb
@@ -1,45 +0,0 @@
-module Scim
-  module Shady
-    class Metadata
-      def initialize(hash)
-        @hash = hash
-      end
-
-      def created
-        created_at
-      end
-
-      def created_at
-        DateTime.parse(to_h['meta']['created'])
-      end
-
-      def last_modified
-        updated_at
-      end
-
-      def updated_at
-        DateTime.parse(to_h['meta']['lastModified'])
-      end
-
-      def version
-        to_h['meta']['version']
-      end
-
-      def location
-        to_h['meta']['location']
-      end
-
-      def resource_type
-        to_h['meta']['resourceType']
-      end
-
-      def user?
-        resource_type == 'User'
-      end
-
-      def to_h
-        @hash
-      end
-    end
-  end
-end
lib/scim/shady/name.rb
@@ -1,17 +0,0 @@
-module Scim
-  module Shady
-    class Name
-      def initialize(hash)
-        @hash = hash
-      end
-
-      def formatted
-        to_h['formatted']
-      end
-
-      def to_h
-        @hash['name']
-      end
-    end
-  end
-end
lib/scim/shady/phone_number.rb
@@ -1,29 +0,0 @@
-module Scim
-  module Shady
-    class PhoneNumber
-      def initialize(hash)
-        @hash = hash
-      end
-
-      def value
-        to_h['value']
-      end
-
-      def type
-        to_h['type']
-      end
-
-      def work?
-        type == 'work'
-      end
-
-      def mobile?
-        type == 'mobile'
-      end
-
-      def to_h
-        @hash
-      end
-    end
-  end
-end
lib/scim/shady/photo.rb
@@ -1,29 +0,0 @@
-module Scim
-  module Shady
-    class Photo
-      def initialize(hash)
-        @hash = hash
-      end
-
-      def value
-        to_h['value']
-      end
-
-      def type
-        to_h['type']
-      end
-
-      def photo?
-        type == 'photo'
-      end
-
-      def thumbnail?
-        type == 'thumbnail'
-      end
-
-      def to_h
-        @hash
-      end
-    end
-  end
-end
lib/scim/shady/resource.rb
@@ -1,25 +0,0 @@
-module Scim
-  module Shady
-    class Resource
-      def initialize(json)
-        @json = json
-      end
-
-      def meta
-        Metadata.new(to_h)
-      end
-
-      def id
-        to_h['id']
-      end
-
-      def to_h
-        @json_hash ||= JSON.parse(to_json)
-      end
-
-      def to_json
-        @json
-      end
-    end
-  end
-end
lib/scim/shady/schemas.rb
@@ -1,17 +0,0 @@
-module Scim
-  module Shady
-    class Schemas
-      CORE = "urn:ietf:params:scim:schemas:core:2.0"
-      GROUP = "#{CORE}:Group"
-      SERVICE_PROVIDER_CONFIG = "#{CORE}:ServiceProviderConfig"
-      USER = "#{CORE}:User"
-    end
-
-    class Messages
-      CORE = "urn:ietf:params:scim:api:messages:2.0"
-      LIST_RESPONSE = "#{CORE}:ListResponse"
-      SEARCH_REQUEST = "#{CORE}:SearchRequest"
-      ERROR = "#{CORE}:Error"
-    end
-  end
-end
lib/scim/shady/service_provider_config.rb
@@ -1,71 +0,0 @@
-module Scim
-  module Shady
-    class ServiceProviderConfig
-      include Buildable
-
-      def initialize(json)
-        @json = json
-      end
-
-      def meta
-        Metadata.new(to_h)
-      end
-
-      def documentation_uri
-        to_h['documentationUri']
-      end
-
-      def patch
-        to_h['patch']['supported']
-      end
-
-      def bulk_supported
-        to_h['bulk']['supported']
-      end
-
-      def bulk_max_operations
-        to_h['bulk']['maxOperations']
-      end
-
-      def bulk_max_payload_size
-        to_h['bulk']['maxPayloadSize']
-      end
-
-      def filter_supported
-        to_h['filter']['supported']
-      end
-
-      def filter_max_results
-        to_h['filter']['maxResults']
-      end
-
-      def change_password_supported
-        to_h['changePassword']['supported']
-      end
-
-      def sort_supported
-        to_h['sort']['supported']
-      end
-
-      def etag_supported
-        to_h['etag']['supported']
-      end
-
-      def authentication_schemes
-        to_h['authenticationSchemes']
-      end
-
-      def to_h
-        @hash ||= JSON.parse(to_json)
-      end
-
-      def to_json
-        @json
-      end
-
-      def self.builder_class
-        Scim::Shady::Builders::ServiceProviderConfig
-      end
-    end
-  end
-end
lib/scim/shady/user.rb
@@ -1,71 +0,0 @@
-module Scim
-  module Shady
-    class User < Resource
-      include Buildable
-
-      def username
-        to_h['userName']
-      end
-
-      def external_id
-        to_h['externalId']
-      end
-
-      def name
-        Name.new(to_h)
-      end
-
-      def addresses
-        to_h['addresses'].map { |x| Address.new(x) }
-      end
-
-      def phone_numbers
-        to_h['phoneNumbers'].map { |x| PhoneNumber.new(x) }
-      end
-
-      def instant_messengers
-        to_h['ims'].map { |x| InstantMessenger.new(x) }
-      end
-
-      def photos
-        to_h['photos'].map { |x| Photo.new(x) }
-      end
-
-      def user_type
-        to_h['userType']
-      end
-
-      def title
-        to_h['title']
-      end
-
-      def preferred_language
-        to_h['preferredLanguage']
-      end
-
-      def locale
-        to_h['locale']
-      end
-
-      def timezone
-        to_h['timezone']
-      end
-
-      def active?
-        to_h['active']
-      end
-
-      def groups
-        to_h['groups'].map { |x| Group.new(x) }
-      end
-
-      def x509_certificates
-        to_h['x509Certificates'].map { |x| X509Certificate.new(x) }
-      end
-
-      def self.builder_class
-        Scim::Shady::Builders::User
-      end
-    end
-  end
-end
lib/scim/shady/version.rb
@@ -1,5 +1,5 @@
 module Scim
   module Shady
-    VERSION = "0.2.1"
+    VERSION = "0.3.1"
   end
 end
lib/scim/shady/x509_certificate.rb
@@ -1,17 +0,0 @@
-module Scim
-  module Shady
-    class X509Certificate
-      def initialize(hash)
-        @hash = hash
-      end
-
-      def value
-        to_h['value']
-      end
-
-      def to_h
-        @hash
-      end
-    end
-  end
-end
lib/scim/shady.rb
@@ -1,23 +1,4 @@
-require "forwardable"
-require "json"
-require "time"
-require "active_support/concern"
-
-require "scim/shady/address"
-require "scim/shady/buildable"
-require "scim/shady/builders"
-require "scim/shady/group"
-require "scim/shady/instant_messenger"
-require "scim/shady/metadata"
-require "scim/shady/name"
-require "scim/shady/phone_number"
-require "scim/shady/photo"
-require "scim/shady/resource"
-require "scim/shady/schemas"
-require "scim/shady/service_provider_config"
-require "scim/shady/user"
 require "scim/shady/version"
-require "scim/shady/x509_certificate"
 
 module Scim
   module Shady
spec/scim/builders/service_provider_config_spec.rb
@@ -1,98 +0,0 @@
-RSpec.describe Scim::Shady::Builders::ServiceProviderConfig do
-  subject { described_class.new }
-
-  describe ".build" do
-    let(:documentation_uri) { FFaker::Internet.uri("https") }
-
-    it 'can specify the documentation url' do
-      subject.documentation_uri = documentation_uri
-      expect(subject.build.documentation_uri).to eql(documentation_uri)
-    end
-
-    it 'can specify patch support' do
-      subject.patch = false
-      expect(subject.build.patch).to be(false)
-
-      subject.patch = true
-      expect(subject.build.patch).to be(true)
-    end
-
-    it 'can configure bulk support' do
-      subject.bulk do |x|
-        x.supported = true
-        x.max_operations = 1_000
-        x.max_payload_size = 1_048_576
-      end
-
-      result = subject.build
-      expect(result.bulk_supported).to be(true)
-      expect(result.bulk_max_operations).to eql(1_000)
-      expect(result.bulk_max_payload_size).to eql(1_048_576)
-    end
-
-    it 'can configure filter support' do
-      subject.filter do |x|
-        x.supported = true
-        x.max_results = 200
-      end
-      result = subject.build
-      expect(result.filter_supported).to be(true)
-      expect(result.filter_max_results).to eql(200)
-    end
-
-    it 'can configure change password support' do
-      subject.change_password_supported = true
-      result = subject.build
-      expect(result.change_password_supported).to be(true)
-    end
-
-    it 'can configure sort support' do
-      subject.sort_supported = true
-      expect(subject.build.sort_supported).to be(true)
-    end
-
-    it 'can configure etag support' do
-      subject.etag_supported = true
-      expect(subject.build.etag_supported).to be(true)
-    end
-
-    it 'can add authentication schemes' do
-      subject.add_authentication_scheme(:oauth_bearer_token)
-      subject.add_authentication_scheme(:http_basic)
-
-      result = subject.build
-      expect(result.authentication_schemes).to match_array([
-        {
-          "name" => "OAuth Bearer Token",
-          "description" => "Authentication scheme using the OAuth Bearer Token Standard",
-          "specUri" => "http://www.rfc-editor.org/info/rfc6750",
-          "documentationUri" => "http://example.com/help/oauth.html",
-          "type" => "oauthbearertoken",
-          "primary" => true,
-        },
-        {
-          "name" => "HTTP Basic",
-          "description" => "Authentication scheme using the HTTP Basic Standard",
-          "specUri" => "http://www.rfc-editor.org/info/rfc2617",
-          "documentationUri" => "http://example.com/help/httpBasic.html",
-          "type" => "httpbasic",
-        }
-      ])
-    end
-
-    it 'can configure metadata' do
-      subject.location = FFaker::Internet.uri("https")
-      subject.created_at = Time.now.utc
-      subject.updated_at = Time.now.utc
-      subject.version = 1
-
-      result = subject.build
-
-      expect(result.meta.location).to eql(subject.location)
-      expect(result.meta.created).to eql(DateTime.parse(subject.created_at.iso8601))
-      expect(result.meta.last_modified).to eql(DateTime.parse(subject.updated_at.iso8601))
-      expect(result.meta.version).to eql(subject.version)
-      expect(result.meta.resource_type).to eql("ServiceProviderConfig")
-    end
-  end
-end
spec/scim/builders/user_spec.rb
@@ -1,142 +0,0 @@
-RSpec.describe Scim::Shady::Builders::User do
-  subject { described_class.new }
-
-  describe ".build" do
-    let(:id) { SecureRandom.uuid }
-    let(:created_at) { Time.now }
-    let(:updated_at) { Time.now }
-    let(:user_url) { FFaker::Internet.uri("https") }
-    let(:user_version) { SecureRandom.uuid }
-    let(:username) { FFaker::Internet.user_name }
-    let(:x509_certificate) { OpenSSL::X509::Certificate.new }
-
-    it 'builds a minimal scim user' do
-      subject.id = id
-      subject.username = username
-      subject.meta do |x|
-        x.created_at = created_at
-        x.updated_at = updated_at
-        x.location = user_url
-        x.version = user_version
-      end
-      result = subject.build
-
-      expect(result.id).to eql(id)
-      expect(result.username).to eql(username)
-      expect(result.meta.created).to eql(DateTime.parse(created_at.utc.iso8601))
-      expect(result.meta.last_modified).to eql(DateTime.parse(updated_at.utc.iso8601))
-      expect(result.meta.version).to eql(user_version)
-      expect(result.meta.location).to eql(user_url)
-      expect(result.meta.resource_type).to eql("User")
-    end
-
-    it 'builds a full representation' do
-      subject.id = "2819c223-7f76-453a-919d-413861904646"
-      subject.external_id = "701984"
-      subject.username = "bjensen@example.com"
-      subject.name do |x|
-        x.formatted = "Ms. Barbara J Jensen, III"
-        x.family_name = "Jensen"
-        x.given_name = "Barbara"
-        x.middle_name = "Jane"
-        x.honorific_prefix = "Ms."
-        x.honorific_suffix = "III"
-      end
-      subject.display_name = "Babs Jensen"
-      subject.nick_name = "Babs"
-      subject.profile_url = "https://login.example.com/bjensen"
-      subject.emails do |x|
-        x.add("bjensen@example.com", type: :work, primary: true)
-        x.add("babs@jensen.org", type: :home)
-      end
-      subject.addresses do |x|
-        x.add(
-          type: :work,
-          street_address: "100 Universal City Plaza",
-          locality: "Hollywood",
-          region: "CA",
-          postal_code: "91608",
-          country: "USA",
-          primary: true
-        )
-        x.add(
-          type: :home,
-          street_address: "456 Hollywood Blvd",
-          locality: "Hollywood",
-          region: "CA",
-          postal_code: "91608",
-          country: "USA",
-        )
-      end
-      subject.phone_numbers do |x|
-        x.add("555-555-5555", type: :work)
-        x.add("555-555-4444", type: :mobile)
-      end
-      subject.instant_messengers do |x|
-        x.add("someaimhandle", type: :aim)
-      end
-      subject.photos do |x|
-        x.add("https://photos.example.com/profilephoto/72930000000Ccne/F", type: :photo)
-        x.add("https://photos.example.com/profilephoto/72930000000Ccne/T", type: :thumbnail)
-      end
-      subject.user_type = "Employee"
-      subject.title = "Tour Guide"
-      subject.preferred_language = "en-US"
-      subject.locale = "en-US"
-      subject.timezone = "America/Los_Angeles"
-      subject.active = true
-      subject.groups do |x|
-        x.add("e9e30dba-f08f-4109-8486-d5c6a331660a", "https://example.com/v2/Groups/e9e30dba-f08f-4109-8486-d5c6a331660a", "Tour Guides")
-        x.add("fc348aa8-3835-40eb-a20b-c726e15c55b5", "https://example.com/v2/Groups/fc348aa8-3835-40eb-a20b-c726e15c55b5", "Employees")
-        x.add("71ddacd2-a8e7-49b8-a5db-ae50d0a5bfd7", "https://example.com/v2/Groups/71ddacd2-a8e7-49b8-a5db-ae50d0a5bfd7",  "US Employees")
-      end
-      subject.x509_certificates do |x|
-        x.add(x509_certificate)
-      end
-      subject.meta do |x|
-        x.created_at = created_at
-        x.updated_at = updated_at
-        x.version = "W\/\"a330bc54f0671c9\""
-        x.location = "https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646"
-      end
-      result = subject.build
-
-      expect(result.external_id).to eql(subject.external_id)
-      expect(result.name.formatted).to eql("Ms. Barbara J Jensen, III")
-      expect(result.addresses.first.formatted).to eql("100 Universal City Plaza\nHollywood, CA 91608 USA")
-      expect(result.addresses.first).to be_primary
-      expect(result.addresses.last.formatted).to eql("456 Hollywood Blvd\nHollywood, CA 91608 USA")
-      expect(result.phone_numbers.first.value).to eql("555-555-5555")
-      expect(result.phone_numbers.first).to be_work
-      expect(result.phone_numbers.last.value).to eql("555-555-4444")
-      expect(result.phone_numbers.last).to be_mobile
-      expect(result.instant_messengers.first.value).to eql("someaimhandle")
-      expect(result.instant_messengers.first.type).to eql("aim")
-      expect(result.photos.first.value).to eql("https://photos.example.com/profilephoto/72930000000Ccne/F")
-      expect(result.photos.first).to be_photo
-      expect(result.photos.last.value).to eql("https://photos.example.com/profilephoto/72930000000Ccne/T")
-      expect(result.photos.last).to be_thumbnail
-      expect(result.user_type).to eql("Employee")
-      expect(result.title).to eql("Tour Guide")
-      expect(result.preferred_language).to eql("en-US")
-      expect(result.locale).to eql("en-US")
-      expect(result.timezone).to eql("America/Los_Angeles")
-      expect(result).to be_active
-      expect(result.groups[0].value).to eql("e9e30dba-f08f-4109-8486-d5c6a331660a")
-      expect(result.groups[0].reference).to eql("https://example.com/v2/Groups/e9e30dba-f08f-4109-8486-d5c6a331660a")
-      expect(result.groups[0].display).to eql("Tour Guides")
-      expect(result.groups[1].value).to eql("fc348aa8-3835-40eb-a20b-c726e15c55b5")
-      expect(result.groups[1].reference).to eql("https://example.com/v2/Groups/fc348aa8-3835-40eb-a20b-c726e15c55b5")
-      expect(result.groups[1].display).to eql("Employees")
-      expect(result.groups[2].value).to eql("71ddacd2-a8e7-49b8-a5db-ae50d0a5bfd7")
-      expect(result.groups[2].reference).to eql("https://example.com/v2/Groups/71ddacd2-a8e7-49b8-a5db-ae50d0a5bfd7")
-      expect(result.groups[2].display).to eql("US Employees")
-      expect(result.x509_certificates.first.value).to eql(x509_certificate.to_pem.gsub(/-----BEGIN CERTIFICATE-----/, '').gsub(/-----END CERTIFICATE-----/, ''))
-      expect(result.meta).to be_user
-      expect(result.meta.created_at).to eql(DateTime.parse(created_at.utc.iso8601))
-      expect(result.meta.updated_at).to eql(DateTime.parse(updated_at.utc.iso8601))
-      expect(result.meta.version).to eql("W\/\"a330bc54f0671c9\"")
-      expect(result.meta.location).to eql("https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646")
-    end
-  end
-end
spec/scim/service_provider_config_spec.rb
@@ -1,19 +0,0 @@
-RSpec.describe Scim::Shady::ServiceProviderConfig do
-  describe ".build" do
-    subject { described_class }
-
-    it 'builds a configuration' do
-      result = subject.build do |builder|
-        builder.bulk do |x|
-          x.supported = true
-          x.max_operations = 1_000
-          x.max_payload_size = 1_048_576
-        end
-      end
-
-      expect(result.bulk_supported).to be(true)
-      expect(result.bulk_max_operations).to eql(1_000)
-      expect(result.bulk_max_payload_size).to eql(1_048_576)
-    end
-  end
-end
spec/scim/shady_spec.rb
@@ -1,5 +1,3 @@
 RSpec.describe Scim::Shady do
-  it "has a version number" do
-    expect(Scim::Shady::VERSION).not_to be nil
-  end
+  specify { expect(Scim::Shady::VERSION).not_to be_nil }
 end
spec/scim/user_spec.rb
@@ -1,82 +0,0 @@
-RSpec.describe Scim::Shady::User do
-  let(:id) { SecureRandom.uuid }
-  let(:created_at) { Time.now }
-  let(:updated_at) { Time.now }
-  let(:user_url) { FFaker::Internet.uri("https") }
-  let(:user_version) { SecureRandom.uuid }
-  let(:username) { FFaker::Internet.user_name }
-
-  describe ".build" do
-    subject { described_class }
-
-    it 'builds a scim user' do
-      result = subject.build do |builder|
-        builder.id = id
-        builder.username = username
-        builder.created_at = created_at
-        builder.updated_at = updated_at
-        builder.location = user_url
-        builder.version = user_version
-      end.to_h
-
-      expect(result['schemas']).to match_array([Scim::Shady::Schemas::USER])
-      expect(result['id']).to eql(id)
-      expect(result['userName']).to eql(username)
-      expect(result['meta']['resourceType']).to eql('User')
-      expect(result['meta']['created']).to eql(created_at.utc.iso8601)
-      expect(result['meta']['lastModified']).to eql(updated_at.utc.iso8601)
-      expect(result['meta']['location']).to eql(user_url)
-      expect(result['meta']['version']).to eql(user_version)
-    end
-  end
-
-  describe ".to_json" do
-    subject { described_class }
-
-    it 'produces valid json' do
-      result = subject.build do |builder|
-        builder.id = id
-        builder.username = username
-        builder.created_at = created_at
-        builder.updated_at = updated_at
-        builder.location = user_url
-        builder.version = user_version
-      end.to_json
-      result = JSON.parse(result)
-
-      expect(result['schemas']).to match_array([Scim::Shady::Schemas::USER])
-      expect(result['id']).to eql(id)
-      expect(result['userName']).to eql(username)
-      expect(result['meta']['resourceType']).to eql('User')
-      expect(result['meta']['created']).to eql(created_at.utc.iso8601)
-      expect(result['meta']['lastModified']).to eql(updated_at.utc.iso8601)
-      expect(result['meta']['location']).to eql(user_url)
-      expect(result['meta']['version']).to eql(user_version)
-    end
-  end
-
-  describe ".new" do
-    it 'parses json' do
-      json = JSON.dump({
-        schemas: [Scim::Shady::Schemas::USER],
-        id: id,
-        userName: username,
-        meta: {
-          resourceType: "User",
-          created: created_at.iso8601,
-          lastModified: updated_at.iso8601,
-          version: user_version,
-          location: user_url,
-        }
-      })
-      subject = described_class.new(json)
-
-      expect(subject.id).to eql(id)
-      expect(subject.username).to eql(username)
-      expect(subject.meta.created.iso8601).to eql(created_at.iso8601)
-      expect(subject.meta.last_modified.iso8601).to eql(updated_at.iso8601)
-      expect(subject.meta.version).to eql(user_version)
-      expect(subject.meta.location).to eql(user_url)
-    end
-  end
-end
scim-shady.gemspec
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
   spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
   spec.require_paths = ["lib"]
 
-  spec.add_dependency "activesupport", ">= 4.2.0"
+  spec.add_dependency "scim-kit", "~> 0.2"
   spec.add_development_dependency "bundler", "~> 1.16"
   spec.add_development_dependency "rake", "~> 10.0"
   spec.add_development_dependency "rspec", "~> 3.0"