Skip to content
index.html 51.3 KiB
Newer Older
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../../sdk/sdk_openapi_translation/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    OpenAPI Translation
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../../sdk/sdk_known_issues/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Known Issues
    
  </span>
  

      </a>
    </li>
  

              
            
    <li class="md-nav__item md-nav__item--nested">
      
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5" >
        
          
          <label class="md-nav__link" for="__nav_5" id="__nav_5_label" tabindex="0">
            
  
  <span class="md-ellipsis">
    Example Clients
  </span>
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_5_label" aria-expanded="false">
          <label class="md-nav__title" for="__nav_5">
            <span class="md-nav__icon md-icon"></span>
            Example Clients
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../../example-clients/example-clients/" class="md-nav__link">
        
  
    <li class="md-nav__item md-nav__item--active md-nav__item--nested">
      
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_6" checked>
          <label class="md-nav__link" for="__nav_6" id="__nav_6_label" tabindex="0">
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_6_label" aria-expanded="true">
          <label class="md-nav__title" for="__nav_6">
            <span class="md-nav__icon md-icon"></span>
            Testing
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../testplan/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    Robot Framework
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
    
  
  
  
    <li class="md-nav__item md-nav__item--active">
      
      <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
      
      
        
      
      
        <label class="md-nav__link md-nav__link--active" for="__toc">
          
  
  </span>
  

          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <a href="./" class="md-nav__link md-nav__link--active">
        
  
  </span>
  

      </a>
      
        

<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  
  
  
    
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      Table of contents
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#requisites" class="md-nav__link">
    <span class="md-ellipsis">
      Requisites
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#first-steps" class="md-nav__link">
    <span class="md-ellipsis">
      First steps
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#remote-capif" class="md-nav__link">
    <span class="md-ellipsis">
      Remote CAPIF
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#capif-flows" class="md-nav__link">
    <span class="md-ellipsis">
      CAPIF Flows
    </span>
  </a>
  
    <nav class="md-nav" aria-label="CAPIF Flows">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#creation-of-user-by-admin" class="md-nav__link">
    <nav class="md-nav" aria-label="Creation of User by Admin">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#01-login_admin" class="md-nav__link">
    <span class="md-ellipsis">
      01-Login_admin
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#02-creation-of-user" class="md-nav__link">
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#publication-of-an-api" class="md-nav__link">
    <span class="md-ellipsis">
      Publication of an API
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Publication of an API">
      <ul class="md-nav__list">
        
  <a href="#03-getauth_provider" class="md-nav__link">
  <a href="#04-onboard_provider" class="md-nav__link">
  <a href="#05-publish_api" class="md-nav__link">
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#calling-the-api" class="md-nav__link">
    <span class="md-ellipsis">
      Calling the API
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Calling the API">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#06-getauth_invoker" class="md-nav__link">
    <span class="md-ellipsis">
      06-getauth_invoker
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#07-onboard_invoker" class="md-nav__link">
    <span class="md-ellipsis">
      07-onboard_invoker
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#08-discover" class="md-nav__link">
    <span class="md-ellipsis">
      08-discover
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#09-security_context" class="md-nav__link">
    <span class="md-ellipsis">
      09-security_context
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#10-get_token" class="md-nav__link">
    <span class="md-ellipsis">
      10-get_token
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#11-call_service" class="md-nav__link">
    <span class="md-ellipsis">
      11-call_service
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#other-requests" class="md-nav__link">
    <span class="md-ellipsis">
      Other requests
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#notes" class="md-nav__link">
    <span class="md-ellipsis">
      Notes
    </span>
  </a>
  
</li>
      
    </ul>
  
</nav>
      
    </li>
  

              
            
          </ul>
        </nav>
      
    </li>
  

    
      
      
  
  
  
  
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_7" >
          <label class="md-nav__link" for="__nav_7" id="__nav_7_label" tabindex="0">
  </span>
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_7_label" aria-expanded="false">
          <label class="md-nav__title" for="__nav_7">
            <span class="md-nav__icon md-icon"></span>
            Sandbox
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../../sandbox/sandbox/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    Introduction
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../../sandbox/requestaccess/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    How to Request Access
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../../sandbox/relevantinfo/" class="md-nav__link">
        
  
    <li class="md-nav__item md-nav__item--nested">
      
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_8" >
        
          
          <label class="md-nav__link" for="__nav_8" id="__nav_8_label" tabindex="0">
            
  
  <span class="md-ellipsis">
    Contribute
    
  </span>
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_8_label" aria-expanded="false">
          <label class="md-nav__title" for="__nav_8">
            <span class="md-nav__icon md-icon"></span>
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../../contribute/documenting/" class="md-nav__link">
        
  
    <li class="md-nav__item">
      <a href="../../FAQ/" class="md-nav__link">
        
  
  </span>
  

      </a>
    </li>
  

    
  </ul>
</nav>
                  </div>
                </div>
              </div>
            
            
              
              <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    

<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  
  
  
    
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      Table of contents
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#requisites" class="md-nav__link">
    <span class="md-ellipsis">
      Requisites
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#first-steps" class="md-nav__link">
    <span class="md-ellipsis">
      First steps
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#remote-capif" class="md-nav__link">
    <span class="md-ellipsis">
      Remote CAPIF
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#capif-flows" class="md-nav__link">
    <span class="md-ellipsis">
      CAPIF Flows
    </span>
  </a>
  
    <nav class="md-nav" aria-label="CAPIF Flows">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#creation-of-user-by-admin" class="md-nav__link">
    <nav class="md-nav" aria-label="Creation of User by Admin">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#01-login_admin" class="md-nav__link">
    <span class="md-ellipsis">
      01-Login_admin
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#02-creation-of-user" class="md-nav__link">
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#publication-of-an-api" class="md-nav__link">
    <span class="md-ellipsis">
      Publication of an API
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Publication of an API">
      <ul class="md-nav__list">
        
  <a href="#03-getauth_provider" class="md-nav__link">
  <a href="#04-onboard_provider" class="md-nav__link">
  <a href="#05-publish_api" class="md-nav__link">
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#calling-the-api" class="md-nav__link">
    <span class="md-ellipsis">
      Calling the API
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Calling the API">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#06-getauth_invoker" class="md-nav__link">
    <span class="md-ellipsis">
      06-getauth_invoker
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#07-onboard_invoker" class="md-nav__link">
    <span class="md-ellipsis">
      07-onboard_invoker
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#08-discover" class="md-nav__link">
    <span class="md-ellipsis">
      08-discover
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#09-security_context" class="md-nav__link">
    <span class="md-ellipsis">
      09-security_context
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#10-get_token" class="md-nav__link">
    <span class="md-ellipsis">
      10-get_token
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#11-call_service" class="md-nav__link">
    <span class="md-ellipsis">
      11-call_service
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#other-requests" class="md-nav__link">
    <span class="md-ellipsis">
      Other requests
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#notes" class="md-nav__link">
    <span class="md-ellipsis">
      Notes
    </span>
  </a>
  
</li>
      
    </ul>
  
</nav>
                  </div>
                </div>
              </div>
            
          
          
            <div class="md-content" data-md-component="content">
              <article class="md-content__inner md-typeset">
                
                  


<p>This section shows how OpenCAPIF is used through requests made with Postman, from the creation of a provider together with the publication of an api, to the creation of an invoker and the consumption of the published api. Everything you need to run the test is in <a href="./Postman-Test.zip" download>Postman-Test.zip</a>.</p>
<h2 id="requisites">Requisites</h2>
<ul>
<li>We will need to have Node.js installed since we will use a small script to create the CSRs of the certificates.</li>
<li>An instance of CAPIF (If it is not local, certain variables would have to be modified both in the Node.js script and in the Postman environment variables).</li>
</ul>
<h2 id="first-steps">First steps</h2>
<ol>
<li>Install the Node dependencies <a href="./package.json" download>package.json</a> to run the script with:</li>
</ol>
<pre><code>npm i
</code></pre>
<ol>
<li>Run the <a href="./script.js" download>script.js</a> with the following command:</li>
</ol>
<pre><code>node script.js
</code></pre>
<ol>
<li>Import Postman collection and environment variables (<a href="./CAPIF.postman_collection.json" download>CAPIF.postman_collection.json</a> and <a href="./CAPIF_ENVIRONMENTS.postman_environment.json" download>CAPIF.postman_environment.json</a>)</li>
<li>Select CAPIF Environment before start testing.</li>
<li>Install the necessary dependencies from requirements.txt using the following command:</li>
<pre><code>pip install -r requirements.txt
</code></pre>
<h2 id="remote-capif">Remote CAPIF</h2>
<p>If the CAPIF is not local, the host and port of both the CAPIF and the register would have to be specified in the variables, and the CAPIF_HOSTNAME in the script, necessary to obtain the server certificate.</p>
<p><strong>Enviroments in Postman</strong></p>
<pre><code>CAPIF_HOSTNAME     capifcore
CAPIF_PORT         8080
REGISTER_HOSTNAME  register
REGISTER_PORT      8084
</code></pre>
<p><strong>Const in script.js</strong></p>
<pre><code>CAPIF_HOSTNAME    capifcore
</code></pre>
<h2 id="capif-flows">CAPIF Flows</h2>
<p>Once the first steps have been taken, we can now use Postman requests. These requests are numbered in the order that must be followed to obtain everything necessary from CAPIF.</p>
<h3 id="creation-of-user-by-admin">Creation of User by Admin</h3>
<p>The first step would be for an administrator to create a user with which a provider and an invoker will be created. To do this, the admin must log in to obtain the token needed in admin requests.</p>
<h4 id="01-login_admin"><strong>01-Login_admin</strong></h4>
<p><img alt="Flow" src="../../images/flows/01_Login_Admin.png" /></p>
<h4 id="02-creation-of-user"><strong>02-Creation of User</strong></h4>
<p><img alt="Flow" src="../../images/flows/02_Creation_of_user.png" /></p>
<h3 id="publication-of-an-api">Publication of an API</h3>
<p>The next step is to register a provider using the user created by the administrator in order to publish an API.</p>
<h4 id="03-getauth_provider"><strong>03-getauth_provider</strong></h4>
<p><img alt="Flow" src="../../images/flows/03_Register_of_AEF_GetAuth.png" /></p>
<h4 id="04-onboard_provider"><strong>04-onboard_provider</strong></h4>
<p><img alt="Flow" src="../../images/flows/04_AEF_API_Provider_registration.png" /></p>
<h4 id="05-publish_api"><strong>05-publish_api</strong></h4>
<p>At this point we move on to using certificate authentication in CAPIF. In Postman it is necessary to add the certificates manually and using more than one certificate for the same host as we do in CAPIF complicates things. For this reason, we use the script to overwrite a certificate and a key when it is necessary to have a specific one.</p>
<p>To configure go to <strong>settings</strong> in Postman and open the <strong>certificates</strong> section. </p>
<ul>
<li>Here, activate the <strong>CA certificates</strong> option and add the <strong>ca_cert.pem</strong> file found in the <strong>Responses</strong> folder.</li>
<li>Adds a client certificate specifying the CAPIF host being used and the files <strong>client_cert.crt</strong> and <strong>client_key.key</strong> in the <strong>Responses</strong> folder.</li>
</ul>
<p>Once this is done, the node script will be in charge of changing the certificate that is necessary in each request.</p>
<p><img alt="Flow" src="../../images/flows/05_AEF_Publish.png" /></p>
<p>Once the api is published, we can start it. In this case we have a test one created in python called <a href="./hello_api.py" download>hello_api.py</a> that can be executed with the following command:</p>
<pre><code>python3 hello_api.py
</code></pre>
<p>The API publication interface is set to localhost with port 8088, so the service must be set up locally. If you wanted to build it on another site, you would have to change the interface description in the body of publish_api.</p>