var assert = require('assert')
  , config = require('../config')
  , fixtures = require('../fixtures')
  , nitrogen = require('../../lib');

describe('apiKey object', function() {
    var service = new nitrogen.Service(config);

    it('should be able to find all api keys for user', function(done) {
        service.authenticate(fixtures.models.user, function(err, session, user) {
            assert(!err);
            assert.notEqual(!session, true);
            assert.notEqual(!user, true);

            nitrogen.ApiKey.find(session, {}, {}, function(err, apiKeys) {
                assert(!err);

                assert(apiKeys.length === 1);
                assert(apiKeys[0].owner === fixtures.models.user.id);

                done();
            });
        });
    });

    it('should be able to create an api key', function(done) {
        service.authenticate(fixtures.models.user, function(err, session, user) {
            assert(!err);
            assert.notEqual(!session, true);
            assert.notEqual(!user, true);

            var apiKey = new nitrogen.ApiKey({
                type: 'app',
                name: 'My App'
            });

            apiKey.create(session, function(err, apiKey) {
                assert(!err);
                assert(apiKey.id);

                done();
            });
        });
    });
});
@@ -1139,16 +1139,65 @@
 'My App'
+,%0A                redirect_uri: 'http://myserver'
 %0A       
@@ -1394,8 +1394,9 @@
  %7D);%0A%7D);
+%0A

add required redirect_uri to test