Create function to add profile to store
Create a function that will create a test profile and add it to the
profile store so that it can be retrieved when testing the profile
REST API endpoints.
@@ -18,7 +18,9 @@ use cylinder::{jwt::JsonWebTokenBuilder, secp256k1::Secp256k1Context, Context, S
use reqwest::blocking::Client;
use serde::Deserialize;
use splinter::admin::messages::AuthorizationType;
+use splinter::biome::profile::store::ProfileBuilder;
use splinter::error::InternalError;
+use splinterd::node::Node;
use splinterd::node::PermissionConfig;
use splinterd::node::RestApiVariant;
@@ -358,3 +360,18 @@ fn new_signer() -> Box<dyn Signer> {
pub struct ServerError {
pub message: String,
}
+
+// Adds a test profile to the user profile store
+fn add_profile(node: &Node) -> Result<(), InternalError> {
+ let profile = ProfileBuilder::new()
+ .with_user_id("test_user_id".into())
+ .with_subject("subject".into())
+ .with_name(Some("name".into()))
+ .build()
+ .expect("Unable to build profile");
+
+ let profile_store = node.user_profile_store();
+ Ok(profile_store
+ .add_profile(profile)
+ .map_err(|err| InternalError::from_source(Box::new(err)))?)
+}
