Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions crates/openshell-server/src/grpc/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16284,6 +16284,45 @@ mod tests {
);
}

#[tokio::test]
async fn provider_env_revision_ignores_unrelated_profile_import_and_delete() {
use crate::provider_profile_sources::stored_provider_profile;
use openshell_core::proto::ProviderProfile;

let store = test_store().await;
let mut provider = test_provider("work-github", "github");
provider.profile_workspace.clear();
store.put_message(&provider).await.unwrap();
let providers = ["work-github".to_string()];
let revision = || compute_provider_env_revision(&store, "default", &providers);
let before = revision().await.unwrap();

let mut unrelated = stored_provider_profile(ProviderProfile {
id: "unrelated".to_string(),
display_name: "Unrelated".to_string(),
..Default::default()
});
unrelated.metadata.as_mut().unwrap().workspace = "default".to_string();
store.put_message(&unrelated).await.unwrap();
assert_eq!(
before,
revision().await.unwrap(),
"unrelated profile import"
);

assert!(
store
.delete(StoredProviderProfile::object_type(), unrelated.object_id())
.await
.unwrap()
);
assert_eq!(
before,
revision().await.unwrap(),
"unrelated profile delete"
);
}

#[tokio::test]
async fn provider_env_revision_changes_when_custom_profile_token_grant_changes() {
use crate::grpc::provider::handle_update_provider_profiles;
Expand Down
6 changes: 5 additions & 1 deletion crates/openshell-server/src/provider_profile_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,11 @@ impl EffectiveProviderProfileCatalog {
fn hash_scoped_profile_revision(entry: &ScopedProfileEntry, hasher: &mut Sha256) {
hasher.update(b"provider-profile-source-entry");
hasher.update(entry.source_id.as_bytes());
hasher.update(entry.source_revision.as_bytes());
// Stored profile revisions already live in the entry payload. Hashing the
// whole source snapshot would make unrelated imports supersede waits.
if !entry.user_managed {
hasher.update(entry.source_revision.as_bytes());
}
let scope_tag: &[u8] = match entry.scope {
ProfileScope::Static => b"static",
ProfileScope::Platform => b"platform",
Expand Down
Loading