Code Monkey home page Code Monkey logo

Comments (2)

mattsmithies avatar mattsmithies commented on July 17, 2024

@justin-atwell @prernaadev01

from guardian.

mattsmithies avatar mattsmithies commented on July 17, 2024

This is the latest test that I have been building out see (https://github.com/dovuofficial/guardian-php-sdk/tree/research/guardian-client):

  it('A dry-run policy can create user, with a role, and submit project data -- read data from filter + ensure status', function ($project) {

      /**
       * 1. Authenticate as registry
       */
      $this->helper->authenticateAsRegistry();

      /**
       * 2. Ensure dry run and (possible) restart state
       */
      //        $this->policy_mode->dryRun();
      //        $this->dry_run_scenario->restart();

      /**
       * 3. Creating a new user in dry run state where a role is assigned.
       */
      $users = $this->dry_run_scenario->createUser(); // Returns a list of all users
      $user = (object) end($users);
      $this->dry_run_scenario->login($user->did);
      $this->policy_workflow->assignRole(GuardianRole::SUPPLIER);

      /**
       * 4. Prepare document
       */
      $document = json_decode($project, true);
      $uuid = $document['uuid'];

      /**
       * 5. Send document to the correct tag
       */
      $tag = "create_ecological_project";
      $this->policy_workflow->sendDocumentToTag($tag, $document);

      // TODO: Use the listener logic (This will increase based off of the current resource load on API)
      sleep(2);

      /**
       * 6. As the "Administrator" filter and fetch the valid block
       */
      // As standard authority (first in the list of dry run users)
      $this->dry_run_scenario->login($users[0]['did']);

      // This is stateful in API.
      $this->policy_workflow->filterByTag("supplier_grid_filter", $uuid);

      $supplier = $this->policy_workflow->dataByTagToBlock("supplier_grid");

      /**
       * Ensure that the expected uuid matches the filter
       */
      expect($supplier->uuid)->toBe($uuid);

      /**
       * Ensure that the expected status matches state
       */
      expect($supplier->getStatus())->toBe("Waiting for approval");

      /**
       * Later: Reset policy state
       */
      // $this->dry_run_scenario->restart();
      // $this->policy_mode->draft();
  });

from guardian.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.