<commit_before>const chai = require('chai');
chai.should();
const {init:initClients} = require("../../utils/clients");
const delay = (duration)=> new Promise(resolve=>setTimeout(resolve,duration));

describe('authoring api', () => {
  let clients;
  before(async () => {
    clients = await initClients();
  });

  describe('/posts /apps/new', () => {
    it('allow creating new app with keys-read permission', async () => {
      const response = await clients.authoring.post('/api/apps?author.name=test&author.email=<EMAIL>')
                                              .send({ name: 'my-app', permissions: ['keys-read'] })
                                              .expect(200);
      
      let {appId, appSecret} = response.body;

      let appClient = await clients.authoring.with(client =>
                      client.set( {"x-client-id": appId, "x-client-secret": appSecret } )
                            .unset("Authorization")
                    );

      await appClient.get('/api/keys/@integration_tests/some_key')
                    .expect(200)

      await appClient.get('/api/keys')
                            .expect(403)
    });

     it('allow creating new app with invalid permission', async () => {
      await clients.authoring.post('/api/apps?author.name=test&author.email=<EMAIL>')
                             .send({ name: 'my-app', permissions: ['admin'] })
                             .expect(400);

      await clients.authoring.post('/api/apps?author.name=test&author.email=<EMAIL>')
                             .send({ name: 'my-app', permissions: ['my-permission'] })
                             .expect(400);
      
    });

  });

});<commit_msg>Update add-app.test.js<commit_after>const chai = require('chai');
chai.should();
const {init:initClients} = require("../../utils/clients");
const delay = (duration)=> new Promise(resolve=>setTimeout(resolve,duration));

describe('authoring api', () => {
  let clients;
  before(async () => {
    clients = await initClients();
  });

  describe('/posts /apps/new', () => {
    it('allow creating new app with keys-read permission', async () => {
      const response = await clients.authoring.post('/api/apps?author.name=test&author.email=<EMAIL>')
                                              .send({ name: 'my-app', permissions: ['keys-read'] })
                                              .expect(200);
      
      let {appId, appSecret} = response.body;

      let appClient = await clients.authoring.with(client =>
                      client.set( {"x-client-id": appId, "x-client-secret": appSecret } )
                            .unset("Authorization")
                    );

      await appClient.get('/api/keys/@integration_tests/some_key')
                    .expect(200)

      await appClient.get('/api/keys')
                            .expect(403)
    }).timeout(5000);

     it('allow creating new app with invalid permission', async () => {
      await clients.authoring.post('/api/apps?author.name=test&author.email=<EMAIL>')
                             .send({ name: 'my-app', permissions: ['admin'] })
                             .expect(400);

      await clients.authoring.post('/api/apps?author.name=test&author.email=<EMAIL>')
                             .send({ name: 'my-app', permissions: ['my-permission'] })
                             .expect(400);
      
    }).timeout(5000);

  });

});

{'fraction_non_alphanumeric': 0.1625802685347344, 'fraction_numerical': 0.011091652072387624, 'mean_word_length': 1.841625207296849, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '129345', 'n_tokens_mistral': 965, 'n_tokens_neox': 924, 'n_words': 171}