|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #[cfg(feature = "robocraft")]
- use libfj::robocraft;
- #[cfg(feature = "robocraft")]
- use libfj::robocraft2;
- #[cfg(feature = "robocraft")]
- use libfj::robocraft::ITokenProvider;
-
- #[cfg(feature = "robocraft")]
- #[test]
- fn robocraft_auth_login() -> Result<(), ()> {
- let token_maybe = robocraft::AuthenticatedTokenProvider::with_email("melon.spoik@gmail.com", "P4$$w0rd");
- assert!(token_maybe.is_ok());
- let token_maybe = robocraft::AuthenticatedTokenProvider::with_username("FJAPIC00L", "P4$$w0rd");
- assert!(token_maybe.is_ok());
- let token_p = token_maybe.unwrap();
- let raw_token_maybe = token_p.token();
- assert!(raw_token_maybe.is_ok());
- println!("Token: {}", raw_token_maybe.unwrap());
- Ok(())
- }
-
- #[cfg(feature = "robocraft")]
- #[test]
- fn robocraft_account() -> Result<(), ()> {
- let token_maybe = robocraft::AuthenticatedTokenProvider::with_username("FJAPIC00L", "P4$$w0rd");
- assert!(token_maybe.is_ok());
- let token_provider = token_maybe.unwrap();
- let account_maybe = token_provider.get_account_info();
- assert!(account_maybe.is_ok());
- let account = account_maybe.unwrap();
- assert_eq!(account.display_name, "FJAPIC00L");
- assert_eq!(account.created_date, "2019-01-18T14:48:09");
- Ok(())
- }
-
- // this requires human-interaction so it's disabled by default
- #[cfg(feature = "robocraft2")]
- #[allow(dead_code)]
- //#[tokio::test]
- async fn robocraft2_account() -> Result<(), ()> {
- let token_maybe = robocraft2::PortalTokenProvider::portal().await;
- assert!(token_maybe.is_ok());
- let token_provider = token_maybe.unwrap();
- let account_maybe = token_provider.get_account_info();
- assert!(account_maybe.is_ok());
- let account = account_maybe.unwrap();
- assert_eq!(account.display_name, "NGniusness");
- assert_eq!(account.created_date, "2014-09-17T21:02:46");
- Ok(())
- }
-
- // this requires human-interaction so it's disabled by default
- #[cfg(feature = "robocraft2")]
- #[allow(dead_code)]
- #[tokio::test]
- async fn robocraft2_simple_account() -> Result<(), ()> {
- let token_maybe = robocraft2::PortalTokenProvider::with_username("FJAPIC00L", "P4$$w0rd").await;
- assert!(token_maybe.is_ok());
- let token_provider = token_maybe.unwrap();
- let account_maybe = token_provider.get_account_info();
- assert!(account_maybe.is_ok());
- let account = account_maybe.unwrap();
- assert_eq!(account.display_name, "FJAPIC00L");
- assert_eq!(account.created_date, "2019-01-18T14:48:09");
- Ok(())
- }
|