Commit 770f76a

mo <mo.khan@gmail.com>
2019-01-04 22:25:50
add meta attributes to service provider config
1 parent dd3febc
lib/scim/kit/v2/templates/service_provider_configuration.json.jbuilder
@@ -22,3 +22,10 @@ json.etag do
   json.supported false
 end
 json.authentication_schemes []
+json.meta do
+  json.location location
+  json.resource_type 'ServiceProviderConfig'
+  json.created created.iso8601
+  json.last_modified last_modified.iso8601
+  json.version version.to_i
+end
lib/scim/kit/v2/service_provider_configuration.rb
@@ -6,7 +6,14 @@ module Scim
       # Represents a scim Service Provider Configuration
       class ServiceProviderConfiguration
         include Templatable
+        attr_reader :location
         attr_accessor :documentation_uri
+        attr_accessor :created, :last_modified, :version
+
+        def initialize(location:)
+          @location = location
+          @version = @created = @last_modified = Time.now
+        end
       end
     end
   end
spec/scim/kit/v2/service_provider_configuration_spec.rb
@@ -1,6 +1,10 @@
 # frozen_string_literal: true
 
 RSpec.describe Scim::Kit::V2::ServiceProviderConfiguration do
+  subject { described_class.new(location: location) }
+  let(:location) { FFaker::Internet.uri('https') }
+  let(:now) { Time.now }
+
   describe "#to_json" do
     let(:result) { JSON.parse(subject.to_json, symbolize_names: true) }
 
@@ -13,6 +17,11 @@ RSpec.describe Scim::Kit::V2::ServiceProviderConfiguration do
     specify { expect(result[:sort][:supported]).to be(false) }
     specify { expect(result[:etag][:supported]).to be(false) }
     specify { expect(result[:authenticationSchemes]).to be_empty }
+    specify { expect(result[:meta][:location]).to eql(location) }
+    specify { expect(result[:meta][:resourceType]).to eql('ServiceProviderConfig') }
+    specify { expect(result[:meta][:created]).to eql(now.iso8601) }
+    specify { expect(result[:meta][:lastModified]).to eql(now.iso8601) }
+    specify { expect(result[:meta][:version]).not_to be_nil }
 
     context "with documentation uri" do
       before do