+ fields: { uri: 'user1_channel@localhost:' + server.port },
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
+ })
+
+ await waitJobs([ server ])
+ })
+ })
+
+ describe('When getting a subscription', function () {
+ it('Should fail with a non authenticated user', async function () {
+ await makeGetRequest({
+ url: server.url,
+ path: path + '/user1_channel@localhost:' + server.port,
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
+ })
+ })
+
+ it('Should fail with bad URIs', async function () {
+ await makeGetRequest({
+ url: server.url,
+ path: path + '/root',
+ token: server.accessToken,
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
+ })
+
+ await makeGetRequest({
+ url: server.url,
+ path: path + '/root@',
+ token: server.accessToken,
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
+ })
+
+ await makeGetRequest({
+ url: server.url,
+ path: path + '/root@hello@',
+ token: server.accessToken,
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
+ })
+ })
+
+ it('Should fail with an unknown subscription', async function () {
+ await makeGetRequest({
+ url: server.url,
+ path: path + '/root1@localhost:' + server.port,
+ token: server.accessToken,
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
+ })
+ })
+
+ it('Should succeed with the correct parameters', async function () {
+ await makeGetRequest({
+ url: server.url,
+ path: path + '/user1_channel@localhost:' + server.port,
+ token: server.accessToken,
+ expectedStatus: HttpStatusCode.OK_200
+ })
+ })
+ })
+
+ describe('When checking if subscriptions exist', function () {
+ const existPath = path + '/exist'
+
+ it('Should fail with a non authenticated user', async function () {
+ await makeGetRequest({
+ url: server.url,
+ path: existPath,
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
+ })
+ })
+
+ it('Should fail with bad URIs', async function () {
+ await makeGetRequest({
+ url: server.url,
+ path: existPath,
+ query: { uris: 'toto' },
+ token: server.accessToken,
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
+ })
+
+ await makeGetRequest({
+ url: server.url,
+ path: existPath,
+ query: { 'uris[]': 1 },
+ token: server.accessToken,
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
+ })
+ })
+
+ it('Should succeed with the correct parameters', async function () {
+ await makeGetRequest({
+ url: server.url,
+ path: existPath,
+ query: { 'uris[]': 'coucou@localhost:' + server.port },
+ token: server.accessToken,
+ expectedStatus: HttpStatusCode.OK_200