Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/paraffin/test/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict'
var request = require('supertest')
process.env.HTTP_PORT = 3000
describe('Broker HTTP Test', () => {
var url = 'localhost:' + process.env.HTTP_PORT.toString()
it('should return 401 if a request cannot be authenticated', function (done) {
request(url)
.get('/resources/notauthenticated')
.expect(401, done)
})
it('should GET an unauthorized access and return 401', function (done) {
request(url)
.get('/resources/hello')
.expect(401, done)
})
it('should PUT an unauthorized access and return 401', function (done) {
request(url)
.put('/resources/hello')
.send('hello world')
.expect(401, done)
})
it('should PUT an authorized access and return 204', function (done) {
request(url)
.put('/resources/mahdi/hello')
.auth('mahdi', 'adrekni')
.set('X-Paraffin-Client-Id', 'm313')
.send('hello mahdi')
.expect(204, done)
})
it('should GET an Authorized access and return 200', function (done) {
request(url)
.get('/resources/mahdi/hello')
.auth('mahdi', 'adrekni')
.set('X-Paraffin-Client-Id', 'm313')
.expect(200, 'hello mahdi', done)
})
it('should POST and GET a topic and its payload', function (done) {
request(url)
.put('/resources/hello')
.auth('username', 'password')
.set('content-type', 'text/plain')
.set('X-Paraffin-Client-Id', 'u911')
.send('hello world')
.expect(204, function () {
request(url)
.get('/resources/hello')
.auth('username', 'password')
.set('X-Paraffin-Client-Id', 'u911')
.expect(200, 'hello world', done)
})
})
})
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0044 ]-- |