-
Notifications
You must be signed in to change notification settings - Fork 10
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
add fields to support servers-side node size #221
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
e77f79a
Merge branch 'master' of https://github.com/pdowler/vos
pdowler 7733356
Merge branch 'master' of https://github.com/opencadc/vos
pdowler db176ef
Merge branch 'master' of https://github.com/pdowler/vos
pdowler d8bf54e
Merge branch 'master' of https://github.com/opencadc/vos
pdowler ea647bb
Merge branch 'master' of https://github.com/opencadc/vos
pdowler f9fbcbe
Merge branch 'master' of https://github.com/opencadc/vos
pdowler 2f376af
Merge branch 'master' of https://github.com/opencadc/vos
pdowler c3e9b48
Merge branch 'master' of https://github.com/opencadc/vos
pdowler 520dab7
Merge branch 'master' of https://github.com/pdowler/vos
pdowler 62cc681
change ContainerNode.delta to Long to allow null
pdowler 0820fb3
Support for allocation owner permissions on the tree
7ddfeba
Reverted an oops
9fbe80b
Small change
08aac5f
Merge pull request #222 from andamian/CADC-13241
pdowler febe6fa
Merge branch 'master' of https://github.com/opencadc/vos
pdowler 78c6d5f
change Node model bytesUsed
pdowler 29d30b5
Merge branch 'master' of https://github.com/pdowler/vos
pdowler 749485d
cadc-vos: update NodeReader/writer to use DataNode.bytesUsed
pdowler 6cab291
minor tweak to NodesTest allocation permission changes
pdowler 1cd5735
add NodePersistecne API
pdowler db57a9f
minor tweaks to VOSpaceAuthorizer and is-allocation unit test (incomp…
pdowler 8b9444a
getAllocationHolders() -> getAllocationParents()
pdowler 2cc0847
change to NodePersistence.isAllocation(ContainerNode)
pdowler 6ec82a3
cavern: use DataNode.bytesUsed instead of node prop
pdowler 46f0400
cavern: improve README
pdowler 61b712c
cavern: remove some cruft accidentally left in previous commit
pdowler abc83d4
Update cavern/README.md
pdowler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
196 changes: 196 additions & 0 deletions
196
cadc-vos-server/src/test/java/org/opencadc/vospace/server/auth/VOSpaceAuthorizerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
/* | ||
************************************************************************ | ||
******************* CANADIAN ASTRONOMY DATA CENTRE ******************* | ||
************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** | ||
* | ||
* (c) 2024. (c) 2024. | ||
* Government of Canada Gouvernement du Canada | ||
* National Research Council Conseil national de recherches | ||
* Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 | ||
* All rights reserved Tous droits réservés | ||
* | ||
* NRC disclaims any warranties, Le CNRC dénie toute garantie | ||
* expressed, implied, or énoncée, implicite ou légale, | ||
* statutory, of any kind with de quelque nature que ce | ||
* respect to the software, soit, concernant le logiciel, | ||
* including without limitation y compris sans restriction | ||
* any warranty of merchantability toute garantie de valeur | ||
* or fitness for a particular marchande ou de pertinence | ||
* purpose. NRC shall not be pour un usage particulier. | ||
* liable in any event for any Le CNRC ne pourra en aucun cas | ||
* damages, whether direct or être tenu responsable de tout | ||
* indirect, special or general, dommage, direct ou indirect, | ||
* consequential or incidental, particulier ou général, | ||
* arising from the use of the accessoire ou fortuit, résultant | ||
* software. Neither the name de l'utilisation du logiciel. Ni | ||
* of the National Research le nom du Conseil National de | ||
* Council of Canada nor the Recherches du Canada ni les noms | ||
* names of its contributors may de ses participants ne peuvent | ||
* be used to endorse or promote être utilisés pour approuver ou | ||
* products derived from this promouvoir les produits dérivés | ||
* software without specific prior de ce logiciel sans autorisation | ||
* written permission. préalable et particulière | ||
* par écrit. | ||
* | ||
* This file is part of the Ce fichier fait partie du projet | ||
* OpenCADC project. OpenCADC. | ||
* | ||
* OpenCADC is free software: OpenCADC est un logiciel libre ; | ||
* you can redistribute it and/or vous pouvez le redistribuer ou le | ||
* modify it under the terms of modifier suivant les termes de | ||
* the GNU Affero General Public la “GNU Affero General Public | ||
* License as published by the License” telle que publiée | ||
* Free Software Foundation, par la Free Software Foundation | ||
* either version 3 of the : soit la version 3 de cette | ||
* License, or (at your option) licence, soit (à votre gré) | ||
* any later version. toute version ultérieure. | ||
* | ||
* OpenCADC is distributed in the OpenCADC est distribué | ||
* hope that it will be useful, dans l’espoir qu’il vous | ||
* but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE | ||
* without even the implied GARANTIE : sans même la garantie | ||
* warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ | ||
* or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF | ||
* PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence | ||
* General Public License for Générale Publique GNU Affero | ||
* more details. pour plus de détails. | ||
* | ||
* You should have received Vous devriez avoir reçu une | ||
* a copy of the GNU Affero copie de la Licence Générale | ||
* General Public License along Publique GNU Affero avec | ||
* with OpenCADC. If not, see OpenCADC ; si ce n’est | ||
* <http://www.gnu.org/licenses/>. pas le cas, consultez : | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
************************************************************************ | ||
*/ | ||
|
||
package org.opencadc.vospace.server.auth; | ||
|
||
import ca.nrc.cadc.auth.HttpPrincipal; | ||
import ca.nrc.cadc.auth.NumericPrincipal; | ||
import java.util.UUID; | ||
import javax.security.auth.Subject; | ||
import org.apache.log4j.Logger; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.opencadc.vospace.ContainerNode; | ||
import org.opencadc.vospace.NodeProperty; | ||
import org.opencadc.vospace.VOS; | ||
|
||
/** | ||
* | ||
* @author pdowler | ||
*/ | ||
public class VOSpaceAuthorizerTest { | ||
private static final Logger log = Logger.getLogger(VOSpaceAuthorizerTest.class); | ||
|
||
public VOSpaceAuthorizerTest() { | ||
} | ||
|
||
@Test | ||
public void testAllocationOwner() { | ||
NumericPrincipal n1 = new NumericPrincipal(UUID.randomUUID()); | ||
HttpPrincipal h1 = new HttpPrincipal("somebody"); | ||
Subject allocationOwner = new Subject(); | ||
allocationOwner.getPrincipals().add(n1); | ||
allocationOwner.getPrincipals().add(h1); | ||
|
||
Subject other = new Subject(); | ||
other.getPrincipals().add(new NumericPrincipal(UUID.randomUUID())); | ||
other.getPrincipals().add(new HttpPrincipal("other")); | ||
|
||
ContainerNode root = new ContainerNode(new UUID(0L, 0L), ""); | ||
root.owner = new Subject(); | ||
root.owner.getPrincipals().add(new NumericPrincipal(UUID.randomUUID())); | ||
|
||
ContainerNode home = new ContainerNode("home"); | ||
home.parent = root; | ||
home.owner = root.owner; | ||
|
||
ContainerNode alloc = new ContainerNode("alloc"); | ||
alloc.parent = home; | ||
alloc.owner = allocationOwner; | ||
|
||
ContainerNode sub1 = new ContainerNode("sub1"); | ||
sub1.parent = alloc; | ||
sub1.owner = other; | ||
|
||
ContainerNode sub2 = new ContainerNode("sub2"); | ||
sub2.parent = sub1; | ||
sub2.owner = other; | ||
|
||
final Subject caller = new Subject(); | ||
final VOSpaceAuthorizer auth = new VOSpaceAuthorizer(); | ||
|
||
// no quota to denote an allocation | ||
caller.getPrincipals().addAll(allocationOwner.getPrincipals()); | ||
Assert.assertFalse("sub2", auth.isAllocationOwner(sub2, caller)); | ||
Assert.assertFalse("sub1", auth.isAllocationOwner(sub1, caller)); | ||
Assert.assertFalse("alloc", auth.isAllocationOwner(alloc, caller)); | ||
Assert.assertFalse("home", auth.isAllocationOwner(home, caller)); | ||
Assert.assertFalse("root", auth.isAllocationOwner(root, caller)); | ||
|
||
// owner of child nodes | ||
caller.getPrincipals().clear(); | ||
caller.getPrincipals().addAll(other.getPrincipals()); | ||
Assert.assertFalse("sub2", auth.isAllocationOwner(sub2, caller)); | ||
Assert.assertFalse("sub1", auth.isAllocationOwner(sub1, caller)); | ||
Assert.assertFalse("alloc", auth.isAllocationOwner(alloc, caller)); | ||
Assert.assertFalse("home", auth.isAllocationOwner(home, caller)); | ||
Assert.assertFalse("root", auth.isAllocationOwner(root, caller)); | ||
|
||
// anon | ||
caller.getPrincipals().clear(); | ||
Assert.assertFalse("sub2", auth.isAllocationOwner(sub2, caller)); | ||
Assert.assertFalse("sub1", auth.isAllocationOwner(sub1, caller)); | ||
Assert.assertFalse("alloc", auth.isAllocationOwner(alloc, caller)); | ||
Assert.assertFalse("home", auth.isAllocationOwner(home, caller)); | ||
Assert.assertFalse("root", auth.isAllocationOwner(root, caller)); | ||
|
||
// random caller | ||
caller.getPrincipals().add(new NumericPrincipal(UUID.randomUUID())); | ||
caller.getPrincipals().add(new HttpPrincipal("caller")); | ||
Assert.assertFalse("sub2", auth.isAllocationOwner(sub2, caller)); | ||
Assert.assertFalse("sub1", auth.isAllocationOwner(sub1, caller)); | ||
Assert.assertFalse("alloc", auth.isAllocationOwner(alloc, caller)); | ||
Assert.assertFalse("home", auth.isAllocationOwner(home, caller)); | ||
Assert.assertFalse("root", auth.isAllocationOwner(root, caller)); | ||
|
||
alloc.getProperties().add(new NodeProperty(VOS.PROPERTY_URI_QUOTA, "1234")); | ||
|
||
Assert.assertFalse("sub2", auth.isAllocationOwner(sub2, caller)); | ||
Assert.assertFalse("sub1", auth.isAllocationOwner(sub1, caller)); | ||
Assert.assertFalse("alloc", auth.isAllocationOwner(alloc, caller)); | ||
Assert.assertFalse("home", auth.isAllocationOwner(home, caller)); | ||
Assert.assertFalse("root", auth.isAllocationOwner(root, caller)); | ||
|
||
// alloc owner | ||
caller.getPrincipals().clear(); | ||
caller.getPrincipals().add(h1); | ||
Assert.assertTrue("sub2", auth.isAllocationOwner(sub2, caller)); | ||
Assert.assertTrue("sub1", auth.isAllocationOwner(sub1, caller)); | ||
//Assert.assertTrue("alloc", auth.isAllocationOwner(alloc, caller)); | ||
Assert.assertFalse("home", auth.isAllocationOwner(home, caller)); | ||
Assert.assertFalse("root", auth.isAllocationOwner(root, caller)); | ||
|
||
// root owner is never an alloc owner | ||
caller.getPrincipals().clear(); | ||
caller.getPrincipals().addAll(root.owner.getPrincipals()); | ||
Assert.assertFalse("sub2", auth.isAllocationOwner(sub2, caller)); | ||
Assert.assertFalse("sub1", auth.isAllocationOwner(sub1, caller)); | ||
Assert.assertFalse("alloc", auth.isAllocationOwner(alloc, caller)); | ||
Assert.assertFalse("home", auth.isAllocationOwner(home, caller)); | ||
Assert.assertFalse("root", auth.isAllocationOwner(root, caller)); | ||
|
||
// this makes a parent allocation that includes the previous allocation | ||
root.getProperties().add(new NodeProperty(VOS.PROPERTY_URI_QUOTA, "1234")); | ||
Assert.assertFalse("sub2", auth.isAllocationOwner(sub2, caller)); | ||
Assert.assertFalse("sub1", auth.isAllocationOwner(sub1, caller)); | ||
// here we bypass the alloc quota and see the root quota | ||
// TODO: is this the right behaviour?? | ||
Assert.assertTrue("alloc", auth.isAllocationOwner(alloc, caller)); | ||
Assert.assertTrue("home", auth.isAllocationOwner(home, caller)); | ||
Assert.assertFalse("root", auth.isAllocationOwner(root, caller)); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to test this after my changes. Depending on the server configuration it's either one or the other. To have both cases cover we need an
int-tests
directory in allocation and one outside.