REST Service for POPCORN - ILIAS
alex
2025-08-12 26df3b2287acca225a1142b27c571252c75e37bd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const expect = require("chai").expect
 
const settings = require("../settings")
const libIlias = require("../lib/libIlias")
const db = require("../lib/db")
const testData = require("./data")
 
/////////////////////////////////////////////////////////////////////////
 
describe("the function importIliasUser", function () {
 
   let lastUserId = null
   const user = testData.user
 
   beforeEach(async function () {
 
   })
 
   afterEach(async function () {
      await deleteUser(lastUserId)
   })
 
   it("should import a new user to ILIAS", async function () {
      const res = await libIlias.importIliasUser(user)
      console.dir(res, {depth: null})
      expect(res).to.have.property("status").and.to.equal("ok")
      expect(res.command).to.equal("importUser")
      expect(res.usr_id).to.be.a("number").above(0)
 
      const {usr_id} = res
      lastUserId = usr_id
      const user2 = await db.getUserByUserId(usr_id)
      console.log(user2)
      expect(user2).to.have.property("login").and.to.equal(user.login)
      expect(user2).to.have.property("usr_id").and.to.equal(res.usr_id)
 
      // const res2 = await libIlias.deleteUser(usr_id)
      // console.log(res2)
      // expect(res2).to.have.property("status").and.to.equal("ok")
      // expect(res2).to.have.property("command").and.to.equal("deleteUser")
   })
 
})
 
/////////////////////////////////////////////////////////////////////////
 
async function deleteUser (usr_id) {
   const res2 = await libIlias.deleteUser(usr_id)
   console.log(res2)
   expect(res2).to.have.property("status").and.to.equal("ok")
   expect(res2).to.have.property("command").and.to.equal("deleteUser")
}