authing_ruby 1.1.3 → 1.1.4
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53d6cdb77ad3c55b067f67fe25749cce6ccfec7ce806dff9cc8e645ee21d3cbf
|
4
|
+
data.tar.gz: f950ec08cd5ea8d36b516fac6118c5fee65bf22095baca57bee388615322df3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d4697fff2570f3e8d43129a35f0e0769404b223e17dbd6e403cb29aafe35227b3001ef703f6c486001b4e44457f41bf2e8bd566f6f0c88e423b52d8b5e22df2
|
7
|
+
data.tar.gz: 314074e61c1d6dfb8ff22ba441f98353aca88ad6c9d34286731569488c7a9b1a99069dc6f55563ed8847e4528a75fa9a7ebaf8e08462b573a907edb5b677bcf9
|
@@ -29,8 +29,10 @@ module AuthingRuby
|
|
29
29
|
"userInfo": userInfo,
|
30
30
|
"keepPassword": keepPassword,
|
31
31
|
}
|
32
|
-
|
33
|
-
|
32
|
+
hash = graphqlAPI.createUser(@graphqlClient, @tokenProvider, variables)
|
33
|
+
user = hash.dig("data", "createUser")
|
34
|
+
return user if user
|
35
|
+
return hash
|
34
36
|
end
|
35
37
|
|
36
38
|
# 修改用户资料
|
@@ -49,8 +51,10 @@ module AuthingRuby
|
|
49
51
|
"id": id,
|
50
52
|
"input": updates
|
51
53
|
}
|
52
|
-
|
53
|
-
|
54
|
+
hash = graphqlAPI.updateUser(@graphqlClient, @tokenProvider, variables)
|
55
|
+
user = hash.dig("data", "updateUser")
|
56
|
+
return user if user
|
57
|
+
return hash
|
54
58
|
end
|
55
59
|
|
56
60
|
# 通过 ID 获取用户信息
|
@@ -59,8 +63,10 @@ module AuthingRuby
|
|
59
63
|
variables = {
|
60
64
|
"id": user_id,
|
61
65
|
}
|
62
|
-
|
63
|
-
|
66
|
+
hash = graphqlAPI.user(@graphqlClient, @tokenProvider, variables)
|
67
|
+
user = hash.dig("data", "user")
|
68
|
+
return user if user
|
69
|
+
return hash
|
64
70
|
end
|
65
71
|
|
66
72
|
# 删除用户
|
@@ -69,9 +75,11 @@ module AuthingRuby
|
|
69
75
|
"id": user_id,
|
70
76
|
}
|
71
77
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
72
|
-
|
73
|
-
return res
|
78
|
+
hash = graphqlAPI.deleteUser(@graphqlClient, @tokenProvider, variables)
|
74
79
|
# {"data":{"deleteUser":{"message":"删除成功!","code":200}}}
|
80
|
+
data = hash.dig("data", "deleteUser")
|
81
|
+
return data if data
|
82
|
+
return hash
|
75
83
|
end
|
76
84
|
|
77
85
|
# 批量删除用户
|
@@ -80,9 +88,11 @@ module AuthingRuby
|
|
80
88
|
"ids": user_ids,
|
81
89
|
}
|
82
90
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
83
|
-
|
84
|
-
return res
|
91
|
+
hash = graphqlAPI.deleteUsers(@graphqlClient, @tokenProvider, variables)
|
85
92
|
# {"data":{"deleteUsers":{"message":"删除成功!","code":200}}}
|
93
|
+
data = hash.dig("data", "deleteUsers")
|
94
|
+
return data if data
|
95
|
+
return hash
|
86
96
|
end
|
87
97
|
|
88
98
|
# 获取用户列表
|
@@ -92,8 +102,10 @@ module AuthingRuby
|
|
92
102
|
"limit": limit,
|
93
103
|
}
|
94
104
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
95
|
-
|
96
|
-
|
105
|
+
hash = graphqlAPI.users(@graphqlClient, @tokenProvider, variables)
|
106
|
+
data = hash.dig("data", "users")
|
107
|
+
return data if data
|
108
|
+
return hash
|
97
109
|
end
|
98
110
|
|
99
111
|
# TODO
|
@@ -117,7 +129,9 @@ module AuthingRuby
|
|
117
129
|
}
|
118
130
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
119
131
|
hash = graphqlAPI.isUserExists(@graphqlClient, @tokenProvider, variables)
|
120
|
-
|
132
|
+
data = hash.dig("data", "isUserExists")
|
133
|
+
return data if data
|
134
|
+
return hash
|
121
135
|
end
|
122
136
|
|
123
137
|
# 查找用户
|
@@ -138,6 +152,8 @@ module AuthingRuby
|
|
138
152
|
}
|
139
153
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
140
154
|
hash = graphqlAPI.findUser(@graphqlClient, @tokenProvider, variables)
|
155
|
+
data = hash.dig("data", "findUser")
|
156
|
+
return data if data
|
141
157
|
return hash
|
142
158
|
end
|
143
159
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# ruby ./lib/test/mini_test/TestManagementClient.rb
|
1
|
+
# ruby ./lib/authing_ruby/test/mini_test/TestManagementClient.rb
|
2
2
|
|
3
3
|
require "minitest/autorun"
|
4
4
|
require "./lib/authing_ruby.rb"
|
@@ -28,16 +28,15 @@ class TestManagementClient < Minitest::Test
|
|
28
28
|
phone: random_phone,
|
29
29
|
password: '123456789',
|
30
30
|
}
|
31
|
-
puts userInfo
|
32
31
|
hash = managementClient.users.create(userInfo)
|
33
32
|
|
34
33
|
# 成功
|
35
|
-
# {"
|
34
|
+
# {"id":"608ab9828eab7e35e81bd732","arn":"arn:cn:authing:60800b8ee5b66b23128b4980:user:608ab9828eab7e35e81bd732","userPoolId":"60800b8ee5b66b23128b4980","status":"Activated","username":"SpongeBob2","email":null,"emailVerified":false,"phone":null,"phoneVerified":false,"unionid":null,"openid":null,"nickname":null,"registerSource":["import:manual"],"photo":"default-user-avatar.png","password":"91b133c2e13e40852505946b7e0c2f04","oauth":null,"token":null,"tokenExpiredAt":null,"loginsCount":0,"lastLogin":null,"lastIP":null,"signedUp":null,"blocked":false,"isDeleted":false,"device":null,"browser":null,"company":null,"name":null,"givenName":null,"familyName":null,"middleName":null,"profile":null,"preferredUsername":null,"website":null,"gender":"U","birthdate":null,"zoneinfo":null,"locale":null,"address":null,"formatted":null,"streetAddress":null,"locality":null,"region":null,"postalCode":null,"city":null,"province":null,"country":null,"createdAt":"2021-04-29T13:49:54+00:00","updatedAt":"2021-04-29T13:49:54+00:00","externalId":null}
|
36
35
|
|
37
36
|
# 失败
|
38
37
|
# {"errors":[{"message":{"code":2026,"message":"用户已存在,请勿重复创建!"},"locations":[{"line":2,"column":3}],"path":["createUser"],"extensions":{"code":"INTERNAL_SERVER_ERROR"}}],"data":null}
|
39
38
|
|
40
|
-
assert(hash.dig("
|
39
|
+
assert(hash.dig("id") != nil, hash)
|
41
40
|
end
|
42
41
|
|
43
42
|
# 创建用户
|
@@ -52,7 +51,7 @@ class TestManagementClient < Minitest::Test
|
|
52
51
|
signedUp: '2020-10-15T17:55:37+08:00' # 原有用户系统记录的用户注册时间
|
53
52
|
}
|
54
53
|
hash = managementClient.users.create(userInfo)
|
55
|
-
assert(hash.dig("
|
54
|
+
assert(hash.dig("id") != nil, hash)
|
56
55
|
end
|
57
56
|
|
58
57
|
# 创建一个用户, 并返回这个用户
|
@@ -67,8 +66,7 @@ class TestManagementClient < Minitest::Test
|
|
67
66
|
end
|
68
67
|
|
69
68
|
managementClient = AuthingRuby::ManagementClient.new(@options)
|
70
|
-
|
71
|
-
user = hash.dig("data", "createUser")
|
69
|
+
user = managementClient.users.create(userInfo)
|
72
70
|
return user
|
73
71
|
end
|
74
72
|
|
@@ -84,11 +82,14 @@ class TestManagementClient < Minitest::Test
|
|
84
82
|
hash = managementClient.users.update(user_id, {
|
85
83
|
nickname: 'Nick',
|
86
84
|
})
|
87
|
-
# puts
|
85
|
+
# puts hash
|
86
|
+
# 成功
|
87
|
+
# {"id"=>"60b902e844428416be3a25b8", "arn"=>"arn:cn:authing:60800b8ee5b66b23128b4980:user:60b902e844428416be3a25b8", "userPoolId"=>"60800b8ee5b66b23128b4980", "status"=>"Activated", "username"=>nil, "email"=>nil, "emailVerified"=>false, "phone"=>"17600009338", "phoneVerified"=>false, "unionid"=>nil, "openid"=>nil, "nickname"=>"Nick", "registerSource"=>["import:manual"], "photo"=>"https://files.authing.co/authing-console/default-user-avatar.png", "password"=>nil, "oauth"=>nil, "token"=>nil, "tokenExpiredAt"=>nil, "loginsCount"=>0, "lastLogin"=>nil, "lastIP"=>nil, "signedUp"=>"2021-06-03T16:27:20+00:00", "blocked"=>false, "isDeleted"=>false, "device"=>nil, "browser"=>nil, "company"=>nil, "name"=>nil, "givenName"=>nil, "familyName"=>nil, "middleName"=>nil, "profile"=>nil, "preferredUsername"=>nil, "website"=>nil, "gender"=>"U", "birthdate"=>nil, "zoneinfo"=>nil, "locale"=>nil, "address"=>nil, "formatted"=>nil, "streetAddress"=>nil, "locality"=>nil, "region"=>nil, "postalCode"=>nil, "city"=>nil, "province"=>nil, "country"=>nil, "createdAt"=>"2021-06-03T16:27:20+00:00", "updatedAt"=>"2021-06-03T16:27:22+00:00", "externalId"=>nil}
|
88
|
+
|
88
89
|
# 如果失败
|
89
90
|
# {"errors":[{"message":{"code":2004,"message":"用户不存在"},"locations":[{"line":2,"column":3}],"path":["updateUser"],"extensions":{"code":"INTERNAL_SERVER_ERROR"}}],"data":null}
|
90
91
|
|
91
|
-
assert(hash.dig("
|
92
|
+
assert(hash.dig("id") != nil, hash)
|
92
93
|
end
|
93
94
|
|
94
95
|
# 测试通过 ID 获取用户信息
|
@@ -99,7 +100,7 @@ class TestManagementClient < Minitest::Test
|
|
99
100
|
|
100
101
|
managementClient = AuthingRuby::ManagementClient.new(@options)
|
101
102
|
hash = managementClient.users.detail(user_id)
|
102
|
-
assert(hash.dig("
|
103
|
+
assert(hash.dig("id") != nil, hash)
|
103
104
|
end
|
104
105
|
|
105
106
|
# 测试删除用户
|
@@ -110,8 +111,8 @@ class TestManagementClient < Minitest::Test
|
|
110
111
|
|
111
112
|
managementClient = AuthingRuby::ManagementClient.new(@options)
|
112
113
|
hash = managementClient.users.delete(user_id)
|
113
|
-
# {"
|
114
|
-
assert(hash.dig("
|
114
|
+
# {"message":"删除成功!","code":200}
|
115
|
+
assert(hash.dig("code") == 200, hash)
|
115
116
|
end
|
116
117
|
|
117
118
|
# 测试删除多个用户
|
@@ -127,16 +128,16 @@ class TestManagementClient < Minitest::Test
|
|
127
128
|
|
128
129
|
managementClient = AuthingRuby::ManagementClient.new(@options)
|
129
130
|
hash = managementClient.users.deleteMany(user_ids)
|
130
|
-
# {"
|
131
|
-
assert(hash.dig("
|
131
|
+
# {"message":"删除成功!","code":200}
|
132
|
+
assert(hash.dig("code") == 200, hash)
|
132
133
|
end
|
133
134
|
|
134
135
|
# 测试获取用户列表
|
135
|
-
# ruby ./lib/test/mini_test/TestManagementClient.rb -n test_list
|
136
|
+
# ruby ./lib/authing_ruby/test/mini_test/TestManagementClient.rb -n test_list
|
136
137
|
def test_list
|
137
138
|
managementClient = AuthingRuby::ManagementClient.new(@options)
|
138
139
|
hash = managementClient.users.list()
|
139
|
-
assert(hash.dig("
|
140
|
+
assert(hash.dig("totalCount") != nil, hash)
|
140
141
|
end
|
141
142
|
|
142
143
|
# 测试 检查用户是否存在 (返回 true | false)
|
@@ -174,8 +175,8 @@ class TestManagementClient < Minitest::Test
|
|
174
175
|
# "email": "haha2@qq.com",
|
175
176
|
# "phone": "13700001111",
|
176
177
|
}
|
177
|
-
|
178
|
-
assert(
|
178
|
+
hash = managementClient.users.find(options)
|
179
|
+
assert(hash.dig("id"), hash)
|
179
180
|
end
|
180
181
|
|
181
182
|
end
|
data/lib/authing_ruby/version.rb
CHANGED