Commit 2a02023
Changed files (2)
lib
scim
shady
spec
scim
builders
lib/scim/shady/user.rb
@@ -1,5 +1,106 @@
module Scim
module Shady
+ class X509Certificate
+ def initialize(hash)
+ @hash = hash
+ end
+
+ def value
+ to_h['value']
+ end
+
+ def to_h
+ @hash
+ end
+ end
+ 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
+ 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
+ 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
+ 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
class Name
def initialize(hash)
@hash = hash
@@ -69,6 +170,53 @@ module Scim
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 meta
+ end
+
class << self
def build
builder do |builder|
spec/scim/builders/user_spec.rb
@@ -109,7 +109,7 @@ RSpec.describe Scim::Shady::Builders::User do
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("someimhandle")
+ 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
@@ -130,7 +130,7 @@ RSpec.describe Scim::Shady::Builders::User do
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).to eql(x509_certificate.to_pem.gsub(/-----BEGIN CERTIFICATE-----/, '').gsub(/-----END CERTIFICATE-----/, ''))
+ 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))