-
-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ff6e39
commit c46e2a8
Showing
5 changed files
with
115 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use crate::common::common::{change_client_identifier, start_authority, AuthorityInfo}; | ||
use ockam::identity::SecureChannels; | ||
use ockam_api::authenticator::direct::{ | ||
OCKAM_ROLE_ATTRIBUTE_ENROLLER_VALUE, OCKAM_ROLE_ATTRIBUTE_KEY, | ||
}; | ||
use ockam_api::authenticator::enrollment_tokens::TokenIssuer; | ||
use ockam_core::Result; | ||
use ockam_node::Context; | ||
use std::collections::BTreeMap; | ||
use std::time::Instant; | ||
|
||
mod common; | ||
|
||
#[ockam_macros::test] | ||
async fn enrollment_token_loop(ctx: &mut Context) -> Result<()> { | ||
let secure_channels = SecureChannels::builder().await?.build(); | ||
|
||
let AuthorityInfo { admins, .. } = start_authority(ctx, secure_channels.clone(), 1).await?; | ||
let admin = &admins[0]; | ||
|
||
let mut attributes = BTreeMap::<String, String>::default(); | ||
attributes.insert( | ||
OCKAM_ROLE_ATTRIBUTE_KEY.to_string(), | ||
OCKAM_ROLE_ATTRIBUTE_ENROLLER_VALUE.to_string(), | ||
); | ||
let otc = admin | ||
.client | ||
.create_token(ctx, attributes.clone(), None, None) | ||
.await | ||
.unwrap(); | ||
|
||
let enroller = secure_channels | ||
.identities() | ||
.identities_creation() | ||
.create_identity() | ||
.await?; | ||
let enroller_client = change_client_identifier(&admin.client, &enroller, None); | ||
|
||
{ | ||
use ockam_api::authenticator::enrollment_tokens::TokenAcceptor; | ||
enroller_client.present_token(ctx, otc).await.unwrap(); | ||
} | ||
|
||
let mut attributes_member = BTreeMap::<String, String>::default(); | ||
attributes_member.insert("KEY".to_string(), "VALUE".to_string()); | ||
|
||
let otc = enroller_client | ||
.create_token(ctx, attributes_member.clone(), None, Some(1024)) | ||
.await | ||
.unwrap(); | ||
|
||
let t1 = Instant::now(); | ||
for _ in 0..1000 { | ||
let member = secure_channels | ||
.identities() | ||
.identities_creation() | ||
.create_identity() | ||
.await?; | ||
let member_client = change_client_identifier(&admin.client, &member, None); | ||
|
||
member_client.present_token(ctx, &otc).await.unwrap(); | ||
|
||
use ockam_api::enroll::enrollment::Enrollment; | ||
|
||
member_client.issue_credential(ctx).await.unwrap(); | ||
} | ||
|
||
let t2 = Instant::now(); | ||
|
||
println!("TIME: {:?}", t2 - t1); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters