extern crate tokio_core;

use rusoto_credential::{InstanceMetadataProvider, ProvideAwsCredentials};
use std::time::Duration;
use tokio_core::reactor::Core;

// This test is marked ignored because it requires special setup.
// It's run with the `credential_integration_test` Makefile target.
#[test]
#[ignore]
fn it_fetches_basic_role() {
    // set env vars to point to local provider
    let mut provider = InstanceMetadataProvider::new();
    provider.set_timeout(Duration::from_secs(5));
    provider.set_to_localhost("8080");

    let creds_future = provider.credentials();
    let mut core = Core::new().unwrap();
    let creds = match core.run(creds_future) {
        Ok(creds) => creds,
        Err(e) => panic!("Got error: {:?}", e),
    };

    assert_eq!(creds.aws_access_key_id(), "Access_key_id_value");
    assert_eq!(creds.aws_secret_access_key(), "Secret_access_key_value");
    assert_eq!(creds.token().as_ref(), Some(&"AAAAA".to_string()));
    let dt = match creds.expires_at().as_ref() {
        Some(d) => d.to_string(),
        None => panic!("Expiration should be present"),
    };
    assert_eq!(dt, "2015-08-04 06:32:37 UTC");
}

extern crate tokio_core;

use rusoto_credential::{InstanceMetadataProvider, ProvideAwsCredentials};
use std::time::Duration;
use tokio_core::reactor::Core;

#[test]
#[ignore]
fn it_fetches_basic_role() {
    // set env vars to point to local provider
    let mut provider = InstanceMetadataProvider::new();
    provider.set_timeout(Duration::from_secs(5));
    provider.set_to_localhost("8080");

    let creds_future = provider.credentials();
    let mut core = Core::new().unwrap();
    let creds = match core.run(creds_future) {
        Ok(creds) => creds,
        Err(e) => panic!("Got error: {:?}", e),
    };

    assert_eq!(creds.aws_access_key_id(), "Access_key_id_value");
    assert_eq!(creds.aws_secret_access_key(), "Secret_access_key_value");
}

--- 
+++ 
@@ -4,6 +4,8 @@
 use std::time::Duration;
 use tokio_core::reactor::Core;
 
+// This test is marked ignored because it requires special setup.
+// It's run with the `credential_integration_test` Makefile target.
 #[test]
 #[ignore]
 fn it_fetches_basic_role() {
@@ -21,4 +23,10 @@
 
     assert_eq!(creds.aws_access_key_id(), "Access_key_id_value");
     assert_eq!(creds.aws_secret_access_key(), "Secret_access_key_value");
+    assert_eq!(creds.token().as_ref(), Some(&"AAAAA".to_string()));
+    let dt = match creds.expires_at().as_ref() {
+        Some(d) => d.to_string(),
+        None => panic!("Expiration should be present"),
+    };
+    assert_eq!(dt, "2015-08-04 06:32:37 UTC");
 }
Add note on why integration test is ignored, check token and expiration for instance profile integration test.
