Guest User

Untitled

a guest
Oct 12th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. class Harness extends TestHarness<TransformerChannel> with TestHarnessAuthMixin<TransformerChannel>, TestHarnessORMMixin {
  2. @override
  3. ManagedContext get context => channel.context;
  4.  
  5. @override
  6. AuthServer get authServer => channel.authServer;
  7.  
  8. Agent publicAgent;
  9. Agent adminAgent;
  10.  
  11. @override
  12. Future onSetUp() async {
  13. await resetData();
  14. publicAgent = await addClient("com.aqueduct.public");
  15. adminAgent = await registerUser("admin", "abracadabra", "admin@bioservo.com");
  16. }
  17.  
  18. Future<Agent> registerUser(String username, String password, String email) async {
  19. final salt = AuthUtility.generateRandomSalt();
  20. final hashedPassword = authServer.hashPassword(password, salt);
  21. var user = User()
  22. ..email = email
  23. ..username = username
  24. ..hashedPassword = hashedPassword
  25. ..salt = salt;
  26. await Query.insertObject(context, user);
  27. return loginUser(publicAgent, username, password);
  28. }
  29.  
  30. @override
  31. Future beforeStart() async {
  32. // add initialization code that will run prior to the test application starting
  33. }
  34.  
  35. @override
  36. Future afterStart() async {
  37. // add initialization code that will run once the test application has started
  38. await resetData();
  39. }
  40.  
  41. @override
  42. Future seed() async {
  43. // restore any static data. called afterStart and after resetData
  44. }
  45. }
Add Comment
Please, Sign In to add comment