what doesnt do anything must go
that sounds like someone
This commit is contained in:
@@ -32,11 +32,6 @@ pub struct IssueEnrollTokenQuery {
|
||||
pub ttl_seconds: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ListEnrollTokenQuery {
|
||||
pub include_expired: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct EnrollTokenStatus {
|
||||
pub enroll_token: String,
|
||||
@@ -200,10 +195,8 @@ pub async fn issue_enroll_token(
|
||||
|
||||
pub async fn list_enroll_tokens(
|
||||
State(state): State<AppState>,
|
||||
Query(query): Query<ListEnrollTokenQuery>,
|
||||
) -> Result<impl IntoResponse, (StatusCode, Json<serde_json::Value>)> {
|
||||
let include_expired = query.include_expired.unwrap_or(false);
|
||||
match state.store.list_enroll_tokens(include_expired).await {
|
||||
match state.store.list_enroll_tokens().await {
|
||||
Ok(tokens) => {
|
||||
if let Err(err) = state
|
||||
.store
|
||||
@@ -217,7 +210,6 @@ pub async fn list_enroll_tokens(
|
||||
latency_ms: None,
|
||||
message: "listed enroll tokens".into(),
|
||||
metadata: serde_json::json!({
|
||||
"include_expired": include_expired,
|
||||
"count": tokens.len(),
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -160,9 +160,6 @@ pub struct ListEnrollTokensArgs {
|
||||
#[arg(long)]
|
||||
pub public_url: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
pub include_expired: bool,
|
||||
|
||||
#[arg(long)]
|
||||
pub json: bool,
|
||||
|
||||
|
||||
@@ -74,10 +74,7 @@ pub async fn issue_enroll_token(args: IssueEnrollTokenArgs) -> Result<()> {
|
||||
pub async fn list_enroll_tokens(args: ListEnrollTokensArgs) -> Result<()> {
|
||||
let settings = config::resolve_list_enroll_token_settings(&args)?;
|
||||
if let Some(base) = settings.public_url.as_deref() {
|
||||
let url = format!(
|
||||
"{}/api/v1/control/enroll-tokens?include_expired={}",
|
||||
base, args.include_expired
|
||||
);
|
||||
let url = format!("{}/api/v1/control/enroll-tokens", base);
|
||||
let response = reqwest::get(&url)
|
||||
.await
|
||||
.with_context(|| format!("failed to call {url}"))?;
|
||||
@@ -118,7 +115,7 @@ pub async fn list_enroll_tokens(args: ListEnrollTokensArgs) -> Result<()> {
|
||||
settings.state_file.display()
|
||||
)
|
||||
})?;
|
||||
let tokens = store.list_enroll_tokens(args.include_expired).await?;
|
||||
let tokens = store.list_enroll_tokens().await?;
|
||||
if args.json {
|
||||
println!(
|
||||
"{}",
|
||||
|
||||
@@ -152,7 +152,7 @@ impl Store {
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn list_enroll_tokens(&self, include_expired: bool) -> Result<Vec<EnrollTokenInfo>> {
|
||||
pub async fn list_enroll_tokens(&self) -> Result<Vec<EnrollTokenInfo>> {
|
||||
let now = now_unix();
|
||||
let mut out = Vec::new();
|
||||
for item in self.enroll_tokens.iter() {
|
||||
@@ -160,9 +160,6 @@ impl Store {
|
||||
let expires_at_unix =
|
||||
decode_expiry(value.as_ref()).context("failed decoding token expiry")?;
|
||||
let expired = expires_at_unix <= now;
|
||||
if !include_expired && expired {
|
||||
continue;
|
||||
}
|
||||
let enroll_token =
|
||||
String::from_utf8(token.to_vec()).context("invalid utf-8 enroll token in db")?;
|
||||
out.push(EnrollTokenInfo {
|
||||
@@ -836,9 +833,11 @@ mod tests {
|
||||
assert!(cleared);
|
||||
|
||||
let listed = store.list_agents_with_nicknames().await;
|
||||
assert!(listed
|
||||
.iter()
|
||||
.any(|(id, name)| id == &issued.agent_id && name.is_none()));
|
||||
assert!(
|
||||
listed
|
||||
.iter()
|
||||
.any(|(id, name)| id == &issued.agent_id && name.is_none())
|
||||
);
|
||||
|
||||
cleanup_dir(&dir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user