class TestApplicationsManagementClient

测试“管理应用” docs.authing.cn/v2/reference/sdk-for-node/management/ApplicationManagementClient.html

Public Instance Methods

setup() click to toggle source
# 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_create() click to toggle source

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

# 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_delete() click to toggle source

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

# 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_findById() click to toggle source

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

# 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_list() click to toggle source

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

# 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