Skip to content

Commit

Permalink
Review: Minor adjustements
Browse files Browse the repository at this point in the history
Signed-off-by: David Schwilk <david.schwilk@bosch.io>
  • Loading branch information
DerSchwilk committed Jun 27, 2022
1 parent 5ce6171 commit 5dab650
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import akka.actor.ActorSystem;

/**
* Transforms a ModifyThing into a CreateThing if the thing does not exist already.
* Transforms a ModifyPolicy into a CreatePolicy if the thing does not exist already.
*/
public final class ModifyToCreatePolicyTransformer implements PreEnforcer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,8 @@ public void createThingWithExistingPolicy() {
final Policy policy = defaultPolicy(policyId);
final SudoRetrievePolicyResponse sudoRetrievePolicyResponse =
SudoRetrievePolicyResponse.of(policyId, policy, DittoHeaders.empty());
final SudoRetrieveThingResponse sudoRetrieveThingResponse =
SudoRetrieveThingResponse.of(thing.toJson(FieldType.all()), DittoHeaders.empty());

// WHEN: received ModifyThing
// WHEN: received CreateThing
final CreateThing createThing = CreateThing.of(thing, null, DEFAULT_HEADERS);

supervisor.tell(createThing, getRef());
Expand All @@ -344,7 +342,7 @@ public void createThingAndPolicy() {
final Thing thing = emptyThing(thingId, null);
final Policy policy = defaultPolicy(policyId);

// WHEN: received ModifyThing
// WHEN: received CreateThing
final var createThing = CreateThing.of(thing, null, DEFAULT_HEADERS);

supervisor.tell(createThing, getRef());
Expand All @@ -368,9 +366,8 @@ public void createThingWithPolicyConflict() {
final ThingId thingId = ThingId.of("thing", UUID.randomUUID().toString());
final PolicyId policyId = PolicyId.of(thingId);
final Thing thing = emptyThing(thingId, null);
final Policy policy = defaultPolicy(policyId);

// WHEN: received ModifyThing
// WHEN: received CreateThing
final var createThing = CreateThing.of(thing, null, DEFAULT_HEADERS);

supervisor.tell(createThing, getRef());
Expand All @@ -393,12 +390,8 @@ public void createThingWithExplicitPolicy() {
final PolicyId policyId = PolicyId.of("policy", UUID.randomUUID().toString());
final Thing thing = emptyThing(thingId, policyId);
final Policy policy = defaultPolicy(policyId);
final SudoRetrieveThingResponse sudoRetrieveThingResponse =
SudoRetrieveThingResponse.of(thing.toJson(FieldType.all()), DittoHeaders.empty());
final SudoRetrievePolicyResponse sudoRetrievePolicyResponse =
SudoRetrievePolicyResponse.of(policyId, policy, DittoHeaders.empty());

// WHEN: received ModifyThing
// WHEN: received CreateThing
final var createThing = CreateThing.of(thing, policy.toJson(), DEFAULT_HEADERS);

supervisor.tell(createThing, getRef());
Expand All @@ -423,10 +416,8 @@ public void createThingWithExplicitPolicyNotAuthorizedBySelf() {
final PolicyId policyId = PolicyId.of("policy", UUID.randomUUID().toString());
final Thing thing = emptyThing(thingId, policyId);
final Policy policy = thingOnlyPolicy(policyId);
final SudoRetrieveThingResponse sudoRetrieveThingResponse =
SudoRetrieveThingResponse.of(thing.toJson(FieldType.all()), DittoHeaders.empty());

// WHEN: received ModifyThing whose inline policy does not permit creation of itself
// WHEN: received CreateThing whose inline policy does not permit creation of itself
final var createThing = CreateThing.of(thing, policy.toJson(), DEFAULT_HEADERS);

supervisor.tell(createThing, getRef());
Expand Down

0 comments on commit 5dab650

Please sign in to comment.