TT#175000 Remove obsolete janus-admin project

Starting with mr10.5 the janus-admin service is obsolete and
no longer available. It is now provided natively by rtpengine.

Change-Id: I11be98c2f4ee29dd01c031aa2dd7b223d7b97d59
master
Guillem Jover 4 years ago
parent 1db5481174
commit b2e5a5a432

@ -1,12 +0,0 @@
root = true
[*.{js,ts,json,html,css,scss,less,md,gitignore,editorconfig}]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

24
.gitignore vendored

@ -1,24 +0,0 @@
# Eclipse
.classpath
.project
.settings/
# Intellij
.idea/
*.iml
*.iws
# Mac
.DS_Store
# Maven
log/
target/
# Node.js
node_modules/
npm-debug.log
# Bower
bower_components/

@ -1,4 +0,0 @@
[gerrit]
host=gerrit.mgm.sipwise.com
port=29418
project=janus-admin

@ -1 +0,0 @@
registry = https://npm-registry.sipwise.com/

@ -1,2 +0,0 @@
all:
true

@ -0,0 +1,5 @@
Repository discontinued
-----------------------
The repository is for historical purposes only, it was obsoleted and
no longer available starting with mr10.5.

@ -1,131 +0,0 @@
JanusAdmin
===========
JanusAdmin is a node.js http client, that implements the entire admin interface of the Janus WebRTC Gateway.
Usage
-------------
```javascript
var JanusAdmin = require('janus-admin').JanusAdmin;
var admin = new JanusAdmin({
url: 'http://janus-admin:7088',
secret: '*****'
});
```
Methods
---------------
### List sessions
```javascript
admin.listSessions().then((res)=>{
console.log(res.sessions)
}).catch((err)=>{
...
});
```
### List handles
```javascript
admin.listHandles(sessionId).then((res)=>{
console.log(res.handles)
}).catch((err)=>{
...
});
```
### Show single handle
```javascript
admin.handleInfo(sessionId, handleId).then((res)=>{
console.log(res.info)
}).catch((err)=>{
...
});
```
### Set the log level
```javascript
admin.setLogLevel([0...7]).then((res)=>{
console.log(res.level)
}).catch((err)=>{
...
});
```
### Set locking debug
```javascript
admin.setLockingDebug([0,1]).then((res)=>{
console.log(res.debug)
}).catch((err)=>{
...
});
```
Methods (token based authentication)
------------------------------------
### Add token
```javascript
admin.addToken(token).then((res)=>{
console.log(res.plugins);
}).catch((err)=>{
...
});
```
### Allow token
```javascript
admin.allowToken(token, plugins).then((res)=>{
console.log(res.plugins);
}).catch((err)=>{
...
});
```
### Disallow token
```javascript
admin.disallowToken(token, plugins).then((res)=>{
console.log(res.plugins);
}).catch((err)=>{
...
});
```
### List all tokens
```javascript
admin.listTokens().then((res)=>{
console.log(res.tokens);
}).catch((err)=>{
...
});
```
### Remove token
```javascript
adminClient.removeToken(token).then((res)=>{
...
}).catch((err)=>{
...
});
```
### Remove all tokens
```javascript
adminClient.removeAllTokens().then((res)=>{
...
}).catch((err)=>{
...
});
```

7
debian/.gitignore vendored

@ -1,7 +0,0 @@
*.debhelper
*.log
*.substvars
/.debhelper/
/debhelper-build-stamp
/files
/ngcp-janus-admin/

174
debian/changelog vendored

@ -1,174 +0,0 @@
janus-admin (5.0.0.0+0~mr10.5.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Wed, 30 Mar 2022 23:58:51 +0200
janus-admin (5.0.0.0+0~mr10.4.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Mon, 24 Jan 2022 16:54:56 +0100
janus-admin (5.0.0.0+0~mr10.3.0.0) unstable; urgency=medium
[ Guillem Jover ]
* [0314024] TT#124273 Update packaging for bullseye
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Tue, 23 Nov 2021 14:17:17 +0100
janus-admin (5.0.0.0+0~mr10.2.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Tue, 05 Oct 2021 13:18:25 +0200
janus-admin (5.0.0.0+0~mr10.1.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Tue, 24 Aug 2021 16:49:50 +0200
janus-admin (5.0.0.0+0~mr10.0.0.0) unstable; urgency=medium
[ Manuel Montecelo ]
* [c61fc3c] TT#118659 Switch Dockerfile from Debian buster to bullseye
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Mon, 14 Jun 2021 16:35:14 +0200
janus-admin (5.0.0.0+0~mr9.5.0.0) unstable; urgency=medium
[ Hans-Peter Herzog ]
* [59d867d] TT#111459 GitHub security alert for janus-admin.git: minimist/lodash/yargs-parser
[ Manuel Montecelo ]
* [84eb9fc] TT#113853 Preparations for release mr8.5.4, missing "mocha" binary
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Tue, 20 Apr 2021 11:56:51 +0200
janus-admin (5.0.0.0+0~mr9.4.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Mon, 15 Feb 2021 17:51:56 +0100
janus-admin (5.0.0.0+0~mr9.3.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Tue, 05 Jan 2021 15:30:49 +0100
janus-admin (5.0.0.0+0~mr9.2.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Mon, 09 Nov 2020 16:23:58 +0100
janus-admin (5.0.0.0+0~mr9.1.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Mon, 31 Aug 2020 21:53:28 +0200
janus-admin (5.0.0.0+0~mr9.0.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Tue, 21 Jul 2020 14:47:52 +0200
janus-admin (5.0.0.0+0~mr8.6.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Tue, 14 Jul 2020 11:51:46 +0200
janus-admin (5.0.0.0+0~mr8.5.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Tue, 19 May 2020 11:07:39 +0200
janus-admin (5.0.0.0+0~mr8.4.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Mon, 16 Mar 2020 11:12:59 +0100
janus-admin (5.0.0.0+0~mr8.3.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Mon, 27 Jan 2020 12:20:30 +0100
janus-admin (5.0.0.0+0~mr8.2.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Mon, 25 Nov 2019 14:53:54 +0100
janus-admin (5.0.0.0+0~mr8.1.0.0) unstable; urgency=medium
[ Alexander Lutay ]
* [0682409] TT#63759 Fix 19113071: replace removed npm-shrinkwrap.json with package-lock.json in Dockerfile
[ Sipwise Jenkins Builder ]
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Tue, 08 Oct 2019 09:07:14 +0200
janus-admin (5.0.0.0+0~mr8.0.0.0) unstable; urgency=medium
[ Alexander Lutay ]
* [d445ec7] TT#60950 Switch janus-admin docker to buster
* [91fac1e] TT#60100 TT#44859 Update janus-admin Dockerfile (remove hardcoded release-trunk-buster)
* [d875383] TT#60100 Use npm-registry.sipwise.com in npm-shrinkwrap.json
[ Guillem Jover ]
* [65c2d31] TT#61954 Update copyright years
* [16952ce] TT#61954 Set debhelper compat level in Build-Depends instead of debian/compat
[ Hans-Peter Herzog ]
* [1911307] TT#63759 janus-admin: Update package dependencies and npm locking version
[ Sipwise Jenkins Builder ]
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Mon, 05 Aug 2019 20:54:06 +0200
janus-admin (5.0.0.0+0~mr7.5.0.0) unstable; urgency=medium
* New release.
-- Sipwise Jenkins Builder <jenkins@sipwise.com> Mon, 17 Jun 2019 14:35:26 +0200
janus-admin (5.0.0.0+0~mr7.4.0.0) unstable; urgency=medium
[ Hans-Peter Herzog ]
* [3fd7c74] TT#5036 Add entry point for package
* [53d1c92] TT#5036 Added debug logger for requests. Normalize url and path via makeUrl.
* [cfeaecd] TT#5036 Add method removeAllTokens
* [947e70e] TT#2723 Created npm shrinkwrap
* [bcd57d0] TT#2723 Javascript syntax highlighting in README
* [d7f2d97] TT#2723 Changed licence
* [cedba63] TT#2723 Added git repo url to package file
* [750ff36] TT#2723 New version
* [1a6e1d3] TT#2723 Lock npm deps
[ Markus Danek ]
* [9f5cea5] TT#15811 Add Dockerfile and testrunner script
[ Sergii Kipot ]
* [aef5fd2] TT#15750 Add our own npm registry cache to .npmrc
[ Alexander Lutay ]
* [f3e1d8e] TT#22402 Switch janus-admin Dockerfile to Debian stretch
[ Guillem Jover ]
* [018bf9a] TT#22072 Update packaging
-- Alex Lutay <alutay@sipwise.com> Thu, 02 May 2019 16:10:37 +0200
janus-admin (5.0.0.0+0~mr5.0.0.0) unstable; urgency=medium
* Initial revision
-- Sergii Kipot <skipot@sipwise.com> Thu, 27 Oct 2016 13:48:23 +0200

16
debian/control vendored

@ -1,16 +0,0 @@
Source: janus-admin
Section: admin
Priority: optional
Maintainer: Sipwise Development Team <support@sipwise.com>
Standards-Version: 4.5.1
Build-Depends:
debhelper-compat (= 13),
Homepage: https://www.sipwise.com/
Package: ngcp-janus-admin
Architecture: all
Depends:
${misc:Depends},
${perl:Depends},
Description: JanusAdmin is a node.js http client, that implements the
entire admin interface of the Janus Web RTC Gateway

23
debian/copyright vendored

@ -1,23 +0,0 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: https://www.sipwise.com/
Upstream-Contact: Sipwise Development Team <support@sipwise.com>
Files: *
Copyright:
Copyright © 2016-2021 Sipwise GmbH, Austria
License: GPL-3+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Comment:
On Debian systems, the full text of the GNU General Public License
version 3 can be found in the file '/usr/share/common-licenses/GPL-3'.

7
debian/rules vendored

@ -1,7 +0,0 @@
#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1
%:
dh "$@"

@ -1 +0,0 @@
3.0 (native)

1350
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,32 +0,0 @@
{
"name": "janus-admin",
"version": "1.0.6",
"main": "src/admin.js",
"scripts": {
"test": "mocha -b --exit -R spec --full-trace test/*-spec.js",
"test-dev": "mocha -b -R spec -w test/*-spec.js"
},
"author": "Hans-Peter Herzog <hherzog@sipwise.com>",
"license": "GPL-3.0",
"description": "JanusAdmin is a node.js http client that implements the admin interface of the Janus WebRTC Gateway",
"keywords": [
"janus"
],
"repository": {
"type": "git",
"url": "https://github.com/sipwise/janus-admin.git"
},
"devDependencies": {
"body-parser": "1.19.0",
"express": "4.17.1",
"mocha": "^8.3.2"
},
"dependencies": {
"chai": "4.2.0",
"debug-logger": "0.4.1",
"lodash": "^4.17.21",
"superagent": "5.1.0",
"uuid": "3.3.2",
"validator": "11.1.0"
}
}

@ -1,253 +0,0 @@
'use strict';
const url = require('url');
const validator = require('validator');
const _ = require('lodash');
const createId = require('uuid').v4;
const assert = require('chai').assert;
const userAgent = require('superagent');
const Response = require('./response').Response;
const ResponseError = require('./error').ResponseError;
const logger = require('debug-logger')('janus:admin');
/**
* @class
*/
class Admin {
constructor(options) {
assert.property(options, 'url', 'Missing option url');
assert(validator.isURL(options.url, {
require_tld: false,
require_protocol: true
}), 'Invalid url', options.url);
assert.property(options, 'secret');
this.url = url.parse(options.url);
this.secret = options.secret;
this.userAgent = options.userAgent || userAgent;
}
makeUrl(path) {
return this.url.format() + path.replace(/^\//g, '');
}
request(req, options) {
return new Promise((resolve, reject)=>{
let path = _.get(options, 'path', '/admin');
req.admin_secret = this.secret;
req.transaction = createId();
logger.debug('Request', req);
this.userAgent.post(this.makeUrl(path)).type('json').send(req).end((err, res)=>{
if(_.isObject(err)) {
return reject(err);
}
logger.debug('Response', res.body);
let response = new Response(req, res.body);
if(response.isSuccess()) {
resolve(response);
} else {
reject(new ResponseError(response));
}
});
});
}
listSessions() {
return new Promise((resolve, reject)=>{
this.request({
janus: 'list_sessions'
}).then((res)=>{
resolve({
sessions: _.get(res.getResponse(), 'sessions', []),
response: res
});
}).catch((err)=>{
reject(err);
});
});
}
listHandles(sessionId) {
return new Promise((resolve, reject)=>{
assert.isString(sessionId);
this.request({
janus: 'list_handles'
}, {
path: '/admin/' + sessionId
}).then((res)=>{
resolve({
handles: _.get(res.getResponse(), 'handles', []),
response: res
});
}).catch((err)=>{
reject(err);
});
});
}
handleInfo(sessionId, handleId) {
return new Promise((resolve, reject)=>{
assert.isString(sessionId);
assert.isString(handleId);
this.request({
janus: 'handle_info'
}, {
path: '/admin/' + sessionId + '/' + handleId
}).then((res)=>{
resolve({
info: _.get(res.getResponse(), 'info', {}),
response: res
});
}).catch((err)=>{
reject(err);
});
});
}
setLogLevel(level) {
return new Promise((resolve, reject)=>{
assert.isNumber(level);
assert(_.inRange(level, 0, 8), 'Invalid log level');
this.request({
janus: 'set_log_level',
level: level
}).then((res)=>{
resolve({
level: res.getResponse().level,
response: res
});
}).catch((err)=>{
reject(err);
});
});
}
setLockingDebug(debug) {
return new Promise((resolve, reject)=>{
assert.isNumber(debug);
this.request({
janus: 'set_locking_debug',
debug: debug
}).then((res)=>{
resolve({
debug: res.getResponse().debug,
response: res
});
}).catch((err)=>{
reject(err);
});
});
}
addToken(token, plugins) {
return new Promise((resolve, reject)=>{
assert.isString(token);
let request = {
janus: 'add_token',
token: token
};
if(_.isArray(plugins)) {
request.plugins = plugins;
}
this.request(request).then((res)=>{
resolve({
plugins: res.getResponse().data.plugins,
response: res
});
}).catch((err)=>{
reject(err);
});
});
}
allowToken(token, plugins) {
return new Promise((resolve, reject)=>{
assert.isString(token);
assert.isArray(plugins);
assert(plugins.length > 0, 'Need at least one plugin to allow');
this.request({
janus: 'allow_token',
token: token,
plugins: plugins
}).then((res)=>{
resolve({
plugins: res.getResponse().data.plugins,
response: res
});
}).catch((err)=>{
reject(err);
});
});
}
disallowToken(token, plugins) {
return new Promise((resolve, reject)=>{
assert.isString(token);
assert.isArray(plugins);
assert(plugins.length > 0, 'Need at least one plugin to disallow');
this.request({
janus: 'disallow_token',
token: token,
plugins: plugins
}).then((res)=>{
resolve({
plugins: res.getResponse().data.plugins,
response: res
});
}).catch((err)=>{
reject(err);
});
});
}
listTokens() {
return new Promise((resolve, reject)=>{
this.request({
janus: 'list_tokens'
}).then((res)=>{
resolve({
tokens: res.getResponse().data.tokens,
response: res
});
}).catch((err)=>{
reject(err);
});
});
}
removeToken(token) {
return new Promise((resolve, reject)=>{
this.request({
janus: 'remove_token',
token: token
}).then((res)=>{
resolve({
response: res
});
}).catch((err)=>{
reject(err);
});
});
}
removeAllTokens() {
return new Promise((resolve, reject)=>{
this.listTokens().then((res)=>{
let tokenRemovePromises = [];
_.forEach(res.tokens, (token)=>{
tokenRemovePromises.push(this.removeToken(token.token));
});
return Promise.all(tokenRemovePromises);
}).then(()=>{
resolve();
}).catch((err)=>{
reject(err);
});
});
}
}
module.exports.JanusAdmin = Admin;

@ -1,20 +0,0 @@
'use strict';
var assert = require('chai').assert;
/**
* @class
*/
class ResponseError extends Error {
constructor(res) {
super();
assert.equal(res.isError(), true, 'No error found in response');
this.name = this.constructor.name;
this.message = res.getErrorMessage();
this.code = res.getErrorCode();
this.response = res;
}
}
module.exports.ResponseError = ResponseError;

@ -1,225 +0,0 @@
'use strict';
process.env.DEBUG = '';
var _ = require('lodash');
var http = require('http');
var express = require('express');
var bodyParser = require('body-parser');
var logger = require('debug-logger')('mock:janus-admin-server');
/**
* @class
*/
class JanusAdminServer {
constructor(options) {
options = options || {};
this.port = options.port || 9000;
this.app = express();
this.http = null;
}
init() {
return new Promise((resolve, reject)=>{
var requestHandler = (req, res, next)=>{ this.dispatchRequest(req, res, next); }
this.app.use(bodyParser.json());
this.app.use((req, res, next)=>{
logger.info('Request', req.originalUrl, req.body);
next();
});
this.app.post('/admin', requestHandler);
this.app.post('/admin/:sessionId', requestHandler);
this.app.post('/admin/:sessionId/:handleId', requestHandler);
this.http = http.createServer(this.app);
this.http.listen(this.port, (err)=>{
if(_.isObject(err)) {
reject(err);
} else {
logger.info('Started');
resolve();
}
});
});
}
getUrl() {
return 'http://localhost:' + this.port;
}
getAdminSecret() {
return 'master';
}
dispatchRequest(req, res, next) {
switch(req.body.janus) {
case 'list_sessions':
this.listSessions(req, res, next);
break;
case 'list_handles':
this.listHandles(req, res, next);
break;
case 'handle_info':
this.handleInfo(req, res, next);
break;
case 'set_log_level':
this.setLogLevel(req, res, next);
break;
case 'set_locking_debug':
this.setLockingDebug(req, res, next);
break;
case 'add_token':
this.addToken(req, res, next);
break;
case 'allow_token':
this.allowToken(req, res, next);
break;
case 'disallow_token':
this.disallowToken(req, res, next);
break;
case 'list_tokens':
this.listTokens(req, res, next);
break;
case 'remove_token':
this.removeToken(req, res, next);
break;
}
}
listSessions(req, res, next) {
res.json({
janus: 'success',
transaction: req.body.transaction,
session: []
});
}
listHandles(req, res, next) {
res.json({
janus: 'success',
transaction: req.body.transaction,
session_id: req.params.sessionId,
handles: []
});
}
handleInfo(req, res, next) {
res.json({
janus: 'success',
transaction: req.body.transaction,
session_id: req.params.sessionId,
handle_id: req.params.handleId,
info: {
}
});
}
setLogLevel(req, res, next) {
res.json({
janus: 'success',
transaction: req.body.transaction,
level: req.body.level
});
}
setLockingDebug(req, res, next) {
res.json({
janus: 'success',
transaction: req.body.transaction,
debug: req.body.debug
});
}
addToken(req, res, next) {
var plugins = [
"janus.plugin.audiobridge",
"janus.plugin.voicemail",
"janus.plugin.echotest",
"janus.plugin.recordplay",
"janus.plugin.videoroom",
"janus.plugin.videocall",
"janus.plugin.streaming",
"janus.plugin.sip"
];
if(_.isArray(req.body.plugins)) {
plugins = req.body.plugins;
}
res.json({
"janus": "success",
"transaction": req.body.transaction,
"data": {
"plugins": plugins
}
});
}
allowToken(req, res, next) {
var plugins = [
"janus.plugin.audiobridge",
"janus.plugin.voicemail"
];
plugins = req.body.plugins.concat(plugins);
res.json({
"janus": "success",
"transaction": req.body.transaction,
"data": {
"plugins": plugins
}
});
}
disallowToken(req, res, next) {
var plugins = [
"janus.plugin.audiobridge",
"janus.plugin.voicemail"
];
res.json({
"janus": "success",
"transaction": req.body.transaction,
"data": {
"plugins": plugins
}
});
}
listTokens(req, res, next) {
res.json({
"janus": "success",
"transaction": req.body.transaction,
"data": {
"tokens": [
{
"token": "abcdef",
"allowed_plugins": [
"janus.plugin.audiobridge",
"janus.plugin.voicemail",
"janus.plugin.recordplay",
"janus.plugin.videocall",
"janus.plugin.streaming",
"janus.plugin.sip",
"janus.plugin.videoroom",
"janus.plugin.echotest"
]
}
]
}
});
}
removeToken(req, res, next) {
res.json({
"janus": "success",
"transaction": req.body.transaction
});
}
}
module.exports.JanusAdminServer = JanusAdminServer;

@ -1,43 +0,0 @@
'use strict';
var _ = require('lodash');
var assert = require('chai').assert;
/**
* @class
*/
class Response {
constructor(req, res) {
assert.property(res, 'janus', 'Invalid response');
this.request = req;
this.response = res;
}
getRequest() {
return this.request;
}
getResponse() {
return this.response;
}
isSuccess() {
return this.response.janus === 'success';
}
isError() {
return this.response.janus === 'error' && _.has(this.response, 'error');
}
getErrorCode() {
return _.get(this.response, 'error.code', null);
}
getErrorMessage() {
return _.get(this.response, 'error.reason', null);
}
}
module.exports.Response = Response;

@ -1,52 +0,0 @@
# DOCKER_NAME=janus-admin-bullseye
FROM docker.mgm.sipwise.com/sipwise-bullseye:latest
# Important! Update this no-op ENV variable when this Dockerfile
# is updated with the current date. It will force refresh of all
# of the base images and things like `apt-get update` won't be using
# old cached versions when the Dockerfile is built.
ENV REFRESHED_AT 2021-05-03
COPY t/sources.list.d/builddeps.list /etc/apt/sources.list.d/
COPY t/sources.list.d/preferences /etc/apt/preferences.d/
RUN apt-get update && \
apt-get install --assume-yes \
curl \
mocha \
nodejs \
npm \
&& \
apt-get clean
ADD package.json /tmp/
ADD package-lock.json /tmp/
ADD README.md /tmp/
WORKDIR /tmp
RUN npm install /tmp
RUN echo "cd /code && ./t/testrunner" >/root/.bash_history
WORKDIR /code
################################################################################
# Instructions for usage (from root folder of git repository)
# ----------------------
# When you want to build the base image from scratch
# (jump to the next section if you don't want to build yourself!).
# The first you need to put the proper NGCP sources at t/sources.list.d/builddeps.list
# for instance, trunk:
# % echo "deb https://deb.sipwise.com/autobuild/ release-trunk-bullseye main" > t/sources.list.d/builddeps.list
# % docker build --tag="janus-admin-bullseye" -f ./t/Dockerfile .
# % docker run --rm -i -t -v $(pwd):/code:ro -v /results janus-admin-bullseye:latest bash
#
# Use the existing docker image:
# % docker pull docker.mgm.sipwise.com/janus-admin-bullseye
# NOTE: run the following command from root folder of git repository:
# % docker run --rm -i -t -v $(pwd):/code:ro -v /results docker.mgm.sipwise.com/janus-admin-bullseye:latest bash
#
# Inside docker:
# cd /code && ./t/testrunner
################################################################################

@ -1,22 +0,0 @@
#!/bin/bash
if ! [ -f /.dockerenv ] && ! grep -q 'devices:/docker' /proc/1/cgroup ; then
echo "Not running inside docker, exiting to avoid data damage." >&2
exit 1
fi
set -e
set -u
echo "### Copying and moving files"
cp -Rf . /tmp/code
ln -s /tmp/node_modules /tmp/code/node_modules
cd /tmp/code/
echo "################################################################################"
echo "Finished main setup, now running tests ..."
npm test
echo "Finished test execution, test execution returned with exit code."
echo "################################################################################"

@ -1,193 +0,0 @@
'use strict';
const Admin = require('../src/admin').JanusAdmin;
const assert = require('chai').assert;
const _ = require('lodash');
const JanusAdminServer = require('../src/mock/janus-admin-server').JanusAdminServer;
describe('Admin', function() {
let adminServer;
let adminClient;
before(function(done){
adminServer = new JanusAdminServer();
adminServer.init().then(()=>{
done();
}).catch((err)=>{
done(err);
});
});
beforeEach(function(){
adminClient = new Admin({
url: adminServer.getUrl(),
secret: adminServer.getAdminSecret()
});
});
it('should make url by given path', function(done){
let url = 'http://localhost:7088';
let finalUrl = url + '/path';
let adminClient1 = new Admin({
url: url,
secret: adminServer.getAdminSecret()
});
let adminClient2 = new Admin({
url: url + '/',
secret: adminServer.getAdminSecret()
});
assert(adminClient1.makeUrl('/path'), finalUrl);
assert(adminClient1.makeUrl('path'), finalUrl);
assert(adminClient2.makeUrl('/path'), finalUrl);
assert(adminClient2.makeUrl('path'), finalUrl);
done();
});
it('should throw an error caused by missing option url', function(done){
try {
adminClient = new Admin({
secret: adminServer.getAdminSecret()
});
} catch(err) {
done();
}
});
it('should throw an error caused by invalid url', function(done){
try {
adminClient = new Admin({
url: 'foo',
secret: adminServer.getAdminSecret()
});
} catch(err) {
done();
}
});
it('should list all sessions', function(done){
adminClient.listSessions().then((res)=>{
assert.isArray(res.sessions);
done();
}).catch((err)=>{
done(err);
});
});
it('should list all handles', function(done){
adminClient.listHandles('123456').then((res)=>{
assert.isArray(res.handles);
done();
}).catch((err)=>{
done(err);
});
});
it('should fetch single handle', function(done){
adminClient.handleInfo('123456', '123456').then((res)=>{
assert.isObject(res.info);
done();
}).catch((err)=>{
done(err);
});
});
it('should set the log level', function(done){
adminClient.setLogLevel(7).then((res)=>{
assert.equal(res.level, 7);
done();
}).catch((err)=>{
done(err);
});
});
it('should throw an error, caused by wrong log level', function(done){
adminClient.setLogLevel(8).then(()=>{
done(new Error());
}).catch(()=>{
done();
});
});
it('should set locking debug', function(done){
adminClient.setLockingDebug(1).then((res)=>{
assert.equal(res.debug, 1);
done();
}).catch((err)=>{
done(err);
});
});
describe('Token based authentication',function(){
let exampleToken = 'abcdef';
let examplePlugins = [
'janus.plugin.videoroom',
'janus.plugin.echotest'
];
it('should add a new token', function(done){
adminClient.addToken(exampleToken).then((res)=>{
assert.isArray(res.plugins);
done();
}).catch((err)=>{
done(err);
});
});
it('should add a new token, that has access to a set of given plugins', function(done){
adminClient.addToken(exampleToken, examplePlugins).then((res)=>{
assert.isArray(res.plugins);
assert.deepEqual(examplePlugins, res.plugins);
done();
}).catch((err)=>{
done(err);
});
});
it('should allow a token to access a set of given plugins', function(done){
adminClient.allowToken(exampleToken, examplePlugins).then((res)=>{
assert.isArray(res.plugins);
assert.deepEqual(_.intersection(res.plugins, examplePlugins), examplePlugins);
done();
}).catch((err)=>{
done(err);
});
});
it('should disallow a token to access a set of given plugins', function(done){
adminClient.disallowToken(exampleToken, examplePlugins).then((res)=>{
assert.isArray(res.plugins);
assert.deepEqual(_.intersection(res.plugins, examplePlugins), []);
done();
}).catch((err)=>{
done(err);
});
});
it('should list all tokens', function(done){
adminClient.listTokens().then((res)=>{
assert.isArray(res.tokens);
done();
}).catch((err)=>{
done(err);
});
});
it('should remove a token', function(done){
adminClient.removeToken(exampleToken).then(()=>{
done();
}).catch((err)=>{
done(err);
});
});
it('should remove all tokens', function(done){
adminClient.removeAllTokens().then(()=>{
done();
}).catch((err)=>{
done(err);
});
});
});
});
Loading…
Cancel
Save