Repository navigation
Conversation
Add `ChannelsCategoryPermission` and `UuidsCategoryPermission`, the `categories` option for `grant_token`, and parsing of category permissions in `parse_token`. Parsed token `resources` and `patterns` are optional now. fix(subscribe): fix `DataStream` and dispatcher deadlocks Fix `DataStream` deadlock between `push_data` and `poll_next` which took `queue` and `waker` locks in opposite order, and `EventDispatcher` deadlock between stream creation and `invalidate`. refactor(client): remove redundant `format!` references Remove redundant references in `format!` arguments of `PubNubClientInstance`, access and presence request builders. build(cargo): update manifest and dev dependencies Add `keywords`, enable `access` feature by default, update `wiremock` and `cucumber`, and register the `integration` test target. docs(readme): update PubNub Rust SDK header Update `README.md` PubNub Rust SDK header. test(access): cover category grants and token parsing Add unit and integration tests for categories-only grants, all permission kinds, token parsing and malformed tokens. test(subscribe): cover stream lock order and wake-ups Add tests for `DataStream` and `EventDispatcher` lock ordering, listener wake-ups and delivery of dispatched batches.
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| BestPractice | 1 minor |
| Complexity | 1 medium |
🟢 Metrics 66 complexity · 124 duplication
Metric Results Complexity 66 Duplication 124
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
|
||
| # Enables all default features | ||
| default = ["publish", "subscribe", "serde", "reqwest", "std", "blocking", "tokio"] | ||
| default = ["publish", "subscribe", "serde", "reqwest", "std", "blocking", "tokio", "access"] |
There was a problem hiding this comment.
Update the readme (so lib.rs) about it, please.
There was a problem hiding this comment.
It was for test purposes and didn't roll it back.
|
|
||
| if let Some(categories) = self.categories.flatten() { | ||
| categories.iter().try_for_each(|cat| { | ||
| if !["channels", "uuids"].contains(&cat.id().as_str()) { |
There was a problem hiding this comment.
Is cat.id() correct here? Shoouldn't we do something like resource_type() here?
| ResourceType::UserId => { | ||
| uuids.insert(perm.id().to_string(), *perm.value()); | ||
| } | ||
| _ => {} |
There was a problem hiding this comment.
Are we sure we want to have deafult here?
There was a problem hiding this comment.
But other ResourceType variants can't be used for resource or pattern. The only two which is left can be used only for categories key under permissions.
| /// | ||
| /// This type used by [`GrantTokenPayload`] to store permissions for specific | ||
| /// resource type. | ||
| #[cfg_attr(feature = "serde", derive(serde::Serialize))] |
There was a problem hiding this comment.
We should always add deriverable types for pub structs.
| #[cfg_attr(feature = "serde", derive(serde::Serialize))] | |
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
There was a problem hiding this comment.
There is more pub structs in the file, but very few are compatible with Copy trait because of HashMap, so instead I'm providing maximum possible list for each.
|
|
||
| impl From<u8> for CategoryPermissions { | ||
| fn from(int: u8) -> Self { | ||
| CategoryPermissions { get: int & 32 != 0 } |
There was a problem hiding this comment.
I understand the AND but please keep this 32 with some name.
Gate `data_stream`, request helpers and `blocking` import so narrow feature builds compile. refactor(parse_token): decouple parse_token from access feature Move permission bits to `permission_bits` in core utils. `parse_token` builds without `access`. `access` re-exports the bits. refactor: address issues reported by PR reviewer docs(readme): standardize README to SDK template
feat(access): add categories permissions to grant token
Add
ChannelsCategoryPermissionandUuidsCategoryPermission, thecategoriesoption forgrant_token, and parsing of category permissions inparse_token. Parsed tokenresourcesandpatternsare optional now.fix(subscribe): fix
DataStreamand dispatcher deadlocksFix
DataStreamdeadlock betweenpush_dataandpoll_nextwhich tookqueueandwakerlocksin opposite order, and
EventDispatcherdeadlock between stream creation andinvalidate.refactor(client): remove redundant
format!referencesRemove redundant references in
format!arguments ofPubNubClientInstance, access and presencerequest builders.
build(cargo): update manifest and dev dependencies
Add
keywords, enableaccessfeature by default, updatewiremockandcucumber, and registerthe
integrationtest target.docs(readme): update PubNub Rust SDK header
Update
README.mdPubNub Rust SDK header.test(access): cover category grants and token parsing
Add unit and integration tests for categories-only grants, all permission kinds, token parsing and
malformed tokens.
test(subscribe): cover stream lock order and wake-ups
Add tests for
DataStreamandEventDispatcherlock ordering, listener wake-ups and delivery ofdispatched batches.