An unofficial collection of APIs used in FreeJam games and mods
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

robocraft_auth.rs 1.2KB

1234567891011121314151617181920212223242526272829303132
  1. #[cfg(feature = "robocraft")]
  2. use libfj::robocraft;
  3. #[cfg(feature = "robocraft")]
  4. use libfj::robocraft::ITokenProvider;
  5. #[cfg(feature = "robocraft")]
  6. #[test]
  7. fn robocraft_auth_login() -> Result<(), ()> {
  8. let token_maybe = robocraft::AuthenticatedTokenProvider::with_email("melon.spoik@gmail.com", "P4$$w0rd");
  9. assert!(token_maybe.is_ok());
  10. let token_maybe = robocraft::AuthenticatedTokenProvider::with_username("FJAPIC00L", "P4$$w0rd");
  11. assert!(token_maybe.is_ok());
  12. let token_p = token_maybe.unwrap();
  13. let raw_token_maybe = token_p.token();
  14. assert!(raw_token_maybe.is_ok());
  15. println!("Token: {}", raw_token_maybe.unwrap());
  16. Ok(())
  17. }
  18. #[cfg(feature = "robocraft")]
  19. #[test]
  20. fn robocraft_account() -> Result<(), ()> {
  21. let token_maybe = robocraft::AuthenticatedTokenProvider::with_username("FJAPIC00L", "P4$$w0rd");
  22. assert!(token_maybe.is_ok());
  23. let token_provider = token_maybe.unwrap();
  24. let account_maybe = token_provider.get_account_info();
  25. assert!(account_maybe.is_ok());
  26. let account = account_maybe.unwrap();
  27. assert_eq!(account.display_name, "FJAPIC00L");
  28. assert_eq!(account.created_date, "2019-01-18T14:48:09");
  29. Ok(())
  30. }