Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@anubhavi25
Copy link
Contributor

… attributes and refactored existing code to adhere to said interface

Signed-off-by: Irina [email protected]

@anubhavi25
Copy link
Contributor Author

import java.util.Set;

public interface AttributeStore {
Set<Attribute> getAttributes(String identifier);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extend this interface to DefaultAttributeStore with method Set getAttributesByCriteria(String identifier, Set criteria)

.thenReturn(subject);
Set<String> criteria = Collections.singleton("someCriteria");
this.defaultSubjectAttributeStore.getAttributesByCriteria(subject.getSubjectIdentifier(), criteria);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This expectedException would change with the new DefaultAttributeStore interface. See above comment

private PolicyEvaluationCacheCircuitBreaker cache;

@SuppressWarnings("unchecked")
@Test(enabled = true)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why explicitly enable the test?

testSubject.setSubjectIdentifier("/test/subject");

Set<Attribute> supplementalSubjectAttributes = new HashSet<>();
supplementalSubjectAttributes.add(new Attribute("https://acs.attributes.int", "site", "sanramon"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this test isn't asserting anything nor expecting any exceptions?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FrankGasparovic , this test is asserting that if subject doesn't have any attributes but supplemental attributes are passed in, then supplemental attributes are returned by the attribute resolver.


public interface AttributeStore {
Set<Attribute> getAttributes(String identifier);
Set<Attribute> getAttributesByCriteria(String identifier, Set<?> criteria);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • getting subject attributes by 'scope' has a specific meaning, so i suggest we keep that naming. getAttributesByScope(String identified, Set<Attribute> scopes) .
  • keep the criteria to a specific type (Set<Attribute>) and name(scopes) as well. When we have another usecase, we can add a new method for it.
  • also raises the question if we should have 2 separate interfaces at this level for Subject and Resource - the underlying implementation can still be shared.


import java.util.Set;

public interface AttributeStore {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use a name which implies that is is read-only. AttributeReader or similar ?

this.privilegeService = privilegeService;
public ResourceAttributeResolver(final AttributeStore resourceAttributeStore,
final String requestResourceUri,
final Set<Attribute> supplementalResourceAttributes) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this format is better, though is not per our current project settings. pls re-concile

MockitoAnnotations.initMocks(this);
}

@Test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add a test for existing resource as well. (and subject for DefaultSubject store)

}

@Test
public void testGetAttributesByCriteriaForNonExistentSubject() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for all criteria related test, isn't it sufficient to test that DefaultSubjectAttributeStore calls the corresponding call on the PrivilegeManagementService with the appropriate criteria/scopes ?

}

@Test
public void testGetSubjectAttributesSubjectFoundWithAttributesAndNoSupplementalAttributes() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testGetResourceAttributesWithAttributesAndNoSupplementalAttributes ?

… attributes and refactored existing code to adhere to said interface

Signed-off-by: Irina <[email protected]>
@anubhavi25 anubhavi25 dismissed sanjeevchopra’s stale review February 16, 2017 19:42

All your comments have been addressed

@sanjeevchopra sanjeevchopra merged commit 15eed81 into develop Feb 16, 2017
@sanjeevchopra sanjeevchopra deleted the US77579 branch February 16, 2017 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants