| | |
| | | |
| | | describe("connection test", function () { |
| | | |
| | | const urlS = settings.ilias.url |
| | | const urlD = new URL(urlS) |
| | | const url = urlD.origin |
| | | |
| | | |
| | | beforeEach(async function () { |
| | | }) |
| | |
| | | |
| | | describe("the ILIAS URL", function () { |
| | | it("should be accessible", async function () { |
| | | const urlS = settings.ilias.url |
| | | const urlD = new URL(urlS) |
| | | const url = urlD.origin |
| | | |
| | | const res = await fetch(url) |
| | | expect(res.status).to.equal(200) |
| | | expect(res.statusText.toUpperCase()).to.equal("OK") |
| | |
| | | expect(text).to.contain("ILIAS") |
| | | }) |
| | | it("should use https", async function () { |
| | | const urlS = settings.ilias.url |
| | | const urlD = new URL(urlS) |
| | | expect(urlD.protocol).to.equal("https:") |
| | | }) |
| | | }) |
| | |
| | | }) |
| | | }) |
| | | |
| | | describe("the rest service", function () { |
| | | it("should be accessible through GET /version", async function () { |
| | | const urlR = `${settings.restUrl}/api/version` |
| | | const res = await fetch(urlR) |
| | | // console.log(res) |
| | | |
| | | const data = await res.json() |
| | | // console.log(data) |
| | | expect(data).to.be.a("object") |
| | | expect(data).to.have.property("version") |
| | | expect(data.version).to.be.a("string") |
| | | }) |
| | | it("should not be accessible without TOKEN", async function () { |
| | | const urlR = `${settings.restUrl}/api/user?offset=0&limit=1` |
| | | const res = await fetch(urlR) |
| | | expect(res.status).to.equal(403) |
| | | }) |
| | | it("should be accessible with TOKEN", async function () { |
| | | const urlR = `${settings.restUrl}/api/user?offset=0&limit=1&token=${settings.authtoken}` |
| | | const res = await fetch(urlR) |
| | | expect(res.status).to.equal(200) |
| | | const data = await res.json() |
| | | // console.log(data) |
| | | |
| | | expect(data).to.be.a("object") |
| | | expect(data.total).to.be.a("number").above(0) |
| | | expect(data.offset).to.equal(0) |
| | | expect(data.limit).to.equal(1) |
| | | |
| | | const data2 = data.data |
| | | expect(data2).to.be.a("array").and.to.be.lengthOf(1) |
| | | |
| | | const user = data2[0] |
| | | expect(user.usr_id).to.be.a("number").above(0) |
| | | expect(user).to.have.property("login") |
| | | expect(user).to.have.property("firstname") |
| | | expect(user).to.have.property("lastname") |
| | | }) |
| | | }) |
| | | |
| | | }) |
| | | |