casino-moped_authenticator 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc4f881350257f5e33a8d782da20cf82c70ba491
4
- data.tar.gz: 8f064650fc86b59e5f706d713f890e42baef14a9
3
+ metadata.gz: 994197499f08f5c429b3aa6e79aa9d01af8b8173
4
+ data.tar.gz: 02a902feebcf9201208bb55ddb816625e7751eeb
5
5
  SHA512:
6
- metadata.gz: b431084b22b452c0ef538e4c52b47a0e9f68b6b6460914d3b42c5c150230bf5af1f691ae6c7bc7d6852f7d9d4613bf43c3072ac63b528e595b72db8f2aa2dd9c
7
- data.tar.gz: 81b51967183a1324e5ea2fa08a1b513904fdd38f9a4f10bb1318780b8967c238c3c601f6b1e9e3506663b45c746ed0db008e53513d7686ffbc1f4f25b2fe98a8
6
+ metadata.gz: 759af790db7a24563218980fd7d29eac4284a10bc746f3b1068edcc38b284ec6b33b75420921a87f6a1ab9007e5f9b45471fdef36c14e62b86923b5f117cb73b
7
+ data.tar.gz: 460dd330d559ab7f656333f9a37e8ee71b61f767abc7642158c729200ad6726b4bd4ededb10e06ee05cea1504748572a3dda03654f107f94c9a7f024ec7c6828
@@ -0,0 +1,9 @@
1
+ ## 0.1.1 (2014-07-09)
2
+
3
+ Bugfixes:
4
+
5
+ - Serialize extra attribute values with the type of `BSON::ObjectId` as `String`
6
+
7
+ ## 0.1.0 (2014-07-08)
8
+
9
+ Initial release
@@ -51,11 +51,11 @@ class CASino::MopedAuthenticator
51
51
  end
52
52
 
53
53
  def extra_attributes(user)
54
- attributes = {}
55
- extra_attributes_option.each do |attribute_name, database_column|
56
- attributes[attribute_name] = user[database_column]
54
+ extra_attributes_option.each_with_object({}) do |(attribute_name, database_column), attributes|
55
+ value = user[database_column]
56
+ value = value.to_s if value.is_a?(Moped::BSON::ObjectId)
57
+ attributes[attribute_name] = value
57
58
  end
58
- attributes
59
59
  end
60
60
 
61
61
  def extra_attributes_option
@@ -1,5 +1,5 @@
1
1
  module CASino
2
2
  class MopedAuthenticator
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
@@ -108,6 +108,30 @@ module CASino
108
108
  end
109
109
  end
110
110
 
111
+ describe 'extra_attributes' do
112
+ let(:extra_attributes) {{
113
+ id: '_id',
114
+ email: 'mail_address',
115
+ roles: 'roles',
116
+ level: 'level',
117
+ }}
118
+
119
+ it 'returns the bson id as a string' do
120
+ create_user(
121
+ 'test_attributes',
122
+ '$5$cegeasjoos$vPX5AwDqOTGocGjehr7k1IYp6Kt.U4FmMUa.1l6NrzD', # password: testpassword
123
+ mail_address: 'mail@example.org',
124
+ roles: ['admin', 'agent'],
125
+ level: 26,
126
+ )
127
+ data = subject.validate('test_attributes', 'testpassword')
128
+ expect(data[:extra_attributes][:email]).to eq 'mail@example.org'
129
+ expect(data[:extra_attributes][:roles]).to eq ['admin', 'agent']
130
+ expect(data[:extra_attributes][:level]).to eq 26
131
+ expect(data[:extra_attributes][:id]).to eq user_with_name('test_attributes')['_id'].to_s
132
+ end
133
+ end
134
+
111
135
  end
112
136
 
113
137
  def create_user(username, password, extra = {})
@@ -121,6 +145,10 @@ module CASino
121
145
  session[options[:collection]].find(username: username).update(password: new_password)
122
146
  end
123
147
 
148
+ def user_with_name(username)
149
+ session[options[:collection]].find(username: username).first
150
+ end
151
+
124
152
  def session
125
153
  @session ||= ::Moped::Session.connect(options[:database_url])
126
154
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: casino-moped_authenticator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gergo Sulymosi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-07 00:00:00.000000000 Z
11
+ date: 2014-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -147,6 +147,7 @@ files:
147
147
  - .gitignore
148
148
  - .rspec
149
149
  - .travis.yml
150
+ - CHANGELOG.md
150
151
  - Gemfile
151
152
  - LICENSE.txt
152
153
  - README.md