Class: TestApplicationsManagementClient

Inherits:
Minitest::Test
  • Object
show all
Defined in:
lib/authing_ruby/test/mini_test/TestApplicationsManagementClient.rb

Overview

Instance Method Summary collapse

Instance Method Details

#setupObject



13
14
15
16
17
18
19
20
# File 'lib/authing_ruby/test/mini_test/TestApplicationsManagementClient.rb', line 13

def setup
  @options = {
    host: 'https://core.authing.cn',
    userPoolId: ENV["userPoolId"],
    secret: ENV["secret"],
  }
  @managementClient = AuthingRuby::ManagementClient.new(@options)
end

#test_createObject

创建应用 ruby ./lib/test/mini_test/TestApplicationsManagementClient.rb -n test_create



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/authing_ruby/test/mini_test/TestApplicationsManagementClient.rb', line 24

def test_create
  res = @managementClient.applications.create({
  name: '应用名称1000',
  identifier: 'app1000',
})
  json = JSON.parse(res.body)
  assert(json["code"] == 200, res.body)
  # 错误情况1
  # {"code":2039,"message":"域名已被占用"}

  # 清理工作:删掉这个应用
  appid = json.dig("data", "id")
  @managementClient.applications.delete(appid)
end

#test_deleteObject

删除应用 ruby ./lib/test/mini_test/TestApplicationsManagementClient.rb -n test_delete



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/authing_ruby/test/mini_test/TestApplicationsManagementClient.rb', line 41

def test_delete
  # 先创建一个应用
  res = @managementClient.applications.create({
  name: '应用名称10',
  identifier: 'app10',
})
  json = JSON.parse(res.body)
  appid = json.dig("data", "id")

  # 然后删除这个应用
  res = @managementClient.applications.delete(appid)
  json = JSON.parse(res.body)
  assert(json["code"] == 200, res.body)
end

#test_findByIdObject

获取应用详情 ruby ./lib/test/mini_test/TestApplicationsManagementClient.rb -n test_findById



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/authing_ruby/test/mini_test/TestApplicationsManagementClient.rb', line 67

def test_findById
  # 先创建应用
  res = @managementClient.applications.create({
  name: '应用名称20',
  identifier: 'app20',
})
  json = JSON.parse(res.body)
  appid = json.dig("data", "id")

  # 然后查询这个应用
  res = @managementClient.applications.findById(appid)
  json = JSON.parse(res.body)
  assert(json["code"] == 200, res.body)

  # 清理工作:最后删除掉这个应用
  @managementClient.applications.delete(appid)
end

#test_listObject

获取应用列表 ruby ./lib/test/mini_test/TestApplicationsManagementClient.rb -n test_list



58
59
60
61
62
63
# File 'lib/authing_ruby/test/mini_test/TestApplicationsManagementClient.rb', line 58

def test_list
  managementClient = AuthingRuby::ManagementClient.new(@options)
  res = managementClient.applications.list()
  json = JSON.parse(res.body)
  assert(json["code"] == 200, res.body)
end