<commit_before>var expect = require('chai').expect,
    supertest = require('supertest-as-promised'),
    express = require('express'),
    mobileApps = require('azure-mobile-apps.express'),
    secret = 'secret', // token and secret are taken directly from http://jwt.io/
    token = '<KEY>',

    app, mobileApp;

// the default configuration uses the in-memory data provider - it does not (yet) support queries
describe('azure-mobile-apps.express.integration.authenticate', function () {
    beforeEach(function () {
        app = express();
        mobileApp = mobileApps({ auth: { secret: secret } });
    });

    it('returns 200 for table requests with valid auth token', function () {
        mobileApp.tables.add('todoitem');
        mobileApp.attach(app);

        return supertest(app)
            .get('/tables/todoitem')
            .set('x-zumo-auth', token)
            .expect(200);
    });

    it('returns 200 for table requests with no auth token', function () {
        mobileApp.tables.add('todoitem');
        mobileApp.attach(app);

        return supertest(app)
            .get('/tables/todoitem')
            .expect(200);
    });

    it('returns 401 for table requests with invalid auth token', function () {
        mobileApp.tables.add('todoitem');
        mobileApp.attach(app);

        return supertest(app)
            .get('/tables/todoitem')
            .set('x-zumo-auth', 'invalid token')
            .expect(401);
    });
});<commit_msg>Added integration tests for authorised tables<commit_after>var expect = require('chai').expect,
    supertest = require('supertest-as-promised'),
    express = require('express'),
    mobileApps = require('azure-mobile-apps.express'),
    secret = 'secret', // token and secret are taken directly from http://jwt.io/
    token = '<KEY>',

    app, mobileApp;

// the default configuration uses the in-memory data provider - it does not (yet) support queries
describe('azure-mobile-apps.express.integration.authenticate', function () {
    beforeEach(function () {
        app = express();
        mobileApp = mobileApps({ auth: { secret: secret } });
    });

    it('returns 200 for table requests with valid auth token', function () {
        mobileApp.tables.add('todoitem');
        mobileApp.attach(app);

        return supertest(app)
            .get('/tables/todoitem')
            .set('x-zumo-auth', token)
            .expect(200);
    });

    it('returns 200 for table requests with no auth token', function () {
        mobileApp.tables.add('todoitem');
        mobileApp.attach(app);

        return supertest(app)
            .get('/tables/todoitem')
            .expect(200);
    });

    it('returns 401 for table requests with invalid auth token', function () {
        mobileApp.tables.add('todoitem');
        mobileApp.attach(app);

        return supertest(app)
            .get('/tables/todoitem')
            .set('x-zumo-auth', 'invalid token')
            .expect(401);
    });

    it('returns 401 for table requests against authorised table with no token', function () {
        mobileApp.tables.add('todoitem', { authorise: true });
        mobileApp.attach(app);

        return supertest(app)
            .get('/tables/todoitem')
            .expect(401);
    });

    it('returns 200 for table requests against authorised table with valid token', function () {
        mobileApp.tables.add('todoitem', { authorise: true });
        mobileApp.attach(app);

        return supertest(app)
            .get('/tables/todoitem')
            .set('x-zumo-auth', token)
            .expect(200);
    });
});
{'fraction_non_alphanumeric': 0.1419068736141907, 'fraction_numerical': 0.013303769401330377, 'mean_word_length': 2.433872502378687, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6723193', 'n_tokens_mistral': 1054, 'n_tokens_neox': 989, 'n_words': 247}