Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database transactions similar api addPolicies, removePolicies #55

Closed
GopherJ opened this issue Feb 12, 2020 · 9 comments
Closed

Database transactions similar api addPolicies, removePolicies #55

GopherJ opened this issue Feb 12, 2020 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@GopherJ
Copy link
Member

GopherJ commented Feb 12, 2020

See casbin/node-casbin#105

@GopherJ
Copy link
Member Author

GopherJ commented Feb 17, 2020

see #59

More unit tests need to be added around this, I'll add them when I got time. There are also many work regarding diesel-adapter.

It must be able to do transaction.

@drholmie
Copy link
Contributor

Hey there! I'm interested in this issue and wanted to know if I can help out with the unit tests.

@GopherJ
Copy link
Member Author

GopherJ commented Feb 26, 2020

@drholmie Hello, thanks for being interested in this. Could you help testing the following methods?

    async fn add_policies(&mut self, paramss: Vec<Vec<&str>>) -> Result<bool>;
    async fn remove_policies(&mut self, paramss: Vec<Vec<&str>>) -> Result<bool>;
    async fn add_named_policies(&mut self, ptype: &str, paramss: Vec<Vec<&str>>) -> Result<bool>;
async fn remove_named_policies(&mut self, ptype: &str, paramss: Vec<Vec<&str>>)
        -> Result<bool>;
    async fn add_grouping_policies(&mut self, paramss: Vec<Vec<&str>>) -> Result<bool>;
    async fn remove_grouping_policies(&mut self, paramss: Vec<Vec<&str>>) -> Result<bool>;
  async fn add_named_grouping_policies(
        &mut self,
        ptype: &str,
        paramss: Vec<Vec<&str>>,
    ) -> Result<bool>;
 async fn remove_named_grouping_policies(
        &mut self,
        ptype: &str,
        paramss: Vec<Vec<&str>>,
    ) -> Result<bool>;
async fn add_permissions_for_user(
        &mut self,
        user: &str,
        permissions: Vec<Vec<&str>>,
    ) -> Result<bool>;
  async fn add_roles_for_user(
        &mut self,
        user: &str,
        roles: Vec<&str>,
        domain: Option<&str>,
    ) -> Result<bool>;

Currently we haven't make diesel-adapter supports this, ideally we should have diesel-adapter supports this by using transaction.

@drholmie
Copy link
Contributor

Awesome! will start with the tests first then. Thank you for clarifying :)

@GopherJ
Copy link
Member Author

GopherJ commented Mar 2, 2020

diesel-adapter now has also:

async fn add_policies(
        &mut self,
        _sec: &str,
        ptype: &str,
        rules: Vec<Vec<&str>>,
    ) -> Result<bool>;

    async fn remove_policies(
        &mut self,
        _sec: &str,
        pt: &str,
        rules: Vec<Vec<&str>>,
    ) -> Result<bool>;

See casbin-rs/diesel-adapter#15

@hsluoyz
Copy link
Member

hsluoyz commented Mar 2, 2020

Closed as resolved.

@hsluoyz hsluoyz closed this as completed Mar 2, 2020
@hsluoyz hsluoyz added the enhancement New feature or request label Mar 2, 2020
@drholmie
Copy link
Contributor

drholmie commented Mar 3, 2020

Hey there @GopherJ wanted to clarify a few things. Firstly, should I open a new issue to better track the completion of tests? Secondly, should I also follow the double insert and remove checks as mentioned in the test_modify_policy_api():

...
        e.remove_policy(vec!["alice", "data1", "read"])
            .await
            .unwrap();
        e.remove_policy(vec!["bob", "data2", "write"])
            .await
            .unwrap();
        e.remove_policy(vec!["alice", "data1", "read"])
            .await
            .unwrap();
        e.add_policy(vec!["eve", "data3", "read"]).await.unwrap();
        e.add_policy(vec!["eve", "data3", "read"]).await.unwrap();
...

for remove_policies and add_policies as well (similarly for the other functions that have double checks)?

@GopherJ
Copy link
Member Author

GopherJ commented Mar 4, 2020

Hello @drholmie , yes u can open a new issue to better track the completion of tests.

Yes u can do that.

@drholmie
Copy link
Contributor

drholmie commented Mar 4, 2020

Thanks for the go ahead @GopherJ !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants