Upgrade tests to 1.1.0

This commit is contained in:
Tobe O 2017-12-22 08:35:46 -05:00
parent 310474438e
commit bd2c6ddb93
2 changed files with 11 additions and 9 deletions

View file

@ -12,7 +12,7 @@ main() {
setUp(() async { setUp(() async {
app = new Angel() app = new Angel()
..lazyParseBodies = true ..lazyParseBodies = true
..before.add((RequestContext req, res) async { ..use((RequestContext req, res) async {
var xUser = req.headers.value('X-User'); var xUser = req.headers.value('X-User');
if (xUser != null) if (xUser != null)
req.inject('user', req.inject('user',
@ -25,7 +25,7 @@ main() {
..use('/artists', new ArtistService()) ..use('/artists', new ArtistService())
..use('/roled', new RoledService()); ..use('/roled', new RoledService());
app.service('user_data') (app.service('user_data') as HookedService)
..beforeIndexed.listen(hooks.queryWithCurrentUser()) ..beforeIndexed.listen(hooks.queryWithCurrentUser())
..beforeCreated.listen(hooks.hashPassword()); ..beforeCreated.listen(hooks.hashPassword());
@ -34,14 +34,16 @@ main() {
..beforeRead.listen(hooks.restrictToOwner()) ..beforeRead.listen(hooks.restrictToOwner())
..beforeCreated.listen(hooks.associateCurrentUser()); ..beforeCreated.listen(hooks.associateCurrentUser());
app.service('roled') (app.service('roled') as HookedService)
..beforeIndexed.listen(new Permission('foo:*').toHook()) ..beforeIndexed.listen(new Permission('foo:*').toHook())
..beforeRead.listen(new Permission('foo:*').toHook(owner: true)); ..beforeRead.listen(new Permission('foo:*').toHook(owner: true));
app.fatalErrorStream.listen((e) { var errorHandler = app.errorHandler;
print('Fatal: ${e.error}'); app.errorHandler = (e, req, res) {
print(e.stack); print(e.toJson());
}); print(e.stackTrace);
return errorHandler(e, req, res);
};
client = await connectTo(app); client = await connectTo(app);
}); });
@ -272,7 +274,7 @@ const Artist _MICHAEL_JACKSON =
class RoledService extends Service { class RoledService extends Service {
@override @override
index([params]) { index([params]) async {
return ['foo']; return ['foo'];
} }

View file

@ -16,7 +16,7 @@ main() {
setUp(() async { setUp(() async {
app = new Angel(); app = new Angel();
app.before.add((RequestContext req, res) async { app.use((RequestContext req, res) async {
// In real life, you'd use auth to check user roles, // In real life, you'd use auth to check user roles,
// but in this case, let's just set the user manually // but in this case, let's just set the user manually
var xRoles = req.headers.value('X-Roles'); var xRoles = req.headers.value('X-Roles');