<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Takahiro Yamamoto</title>
    <description>The latest articles on DEV Community by Takahiro Yamamoto (@yamamo).</description>
    <link>https://dev.to/yamamo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F42912%2Fce7156a7-0819-4240-8776-486b6905aac3.png</url>
      <title>DEV Community: Takahiro Yamamoto</title>
      <link>https://dev.to/yamamo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yamamo"/>
    <language>en</language>
    <item>
      <title>mTLS in CloudHub 2.0 : What Developers Need to Know</title>
      <dc:creator>Takahiro Yamamoto</dc:creator>
      <pubDate>Mon, 28 Aug 2023 11:21:55 +0000</pubDate>
      <link>https://dev.to/yamamo/mtls-in-cloudhub-20-what-developers-need-to-know-apj</link>
      <guid>https://dev.to/yamamo/mtls-in-cloudhub-20-what-developers-need-to-know-apj</guid>
      <description>&lt;h2&gt;
  
  
  Understanding mTLS
&lt;/h2&gt;

&lt;p&gt;Before diving into the specifics of CloudHub, let's briefly touch on mTLS. mTLS is a two-way authentication process between the client and server. While traditional SSL/TLS ensures server-side security, mTLS ensures that both the client and server authenticate each other.&lt;br&gt;
To harness mTLS in CloudHub, developers must ensure that every API consumer is mTLS compatible. But, as in any real-world scenario, there might be a mix of consumers - some capable of mTLS and some not.&lt;/p&gt;

&lt;h2&gt;
  
  
  mTLS in CloudHub 1.0
&lt;/h2&gt;

&lt;p&gt;In CloudHub 1.0, by setting the Dedicated Load Balancer (DLB) 'Client Certificate Validation' to 'Optional,' API access was granted even to those consumers that couldn't handle mTLS. Developers could then inspect the 'X-SSL-Client-Verify' header in their APIs to ascertain whether a valid client certificate was transmitted.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxglte46ksflxstkoiva6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxglte46ksflxstkoiva6.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  mTLS in CloudHub 2.0
&lt;/h2&gt;

&lt;p&gt;The landscape has shifted a bit in CloudHub 2.0. Unlike its predecessor, CloudHub 2.0 doesn't offer the flexibility to optionally set mTLS. Instead, developers need to prepare two distinct endpoints - one with mTLS enabled and one without. The crucial decision lies in the application's Ingress settings, where developers specify which endpoint to use based on whether mTLS is required or not.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2s29f5ozdomu396tmov5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2s29f5ozdomu396tmov5.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fli9v4r0yk55jxi7792dl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fli9v4r0yk55jxi7792dl.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Adapting to CloudHub 2.0's mTLS implementation requires some rethinking and retooling, especially for those who have been operating with mixed API consumer environments in CloudHub 1.0. By understanding the core changes and preparing adequately, developers can continue to ensure secure and seamless integrations in the MuleSoft ecosystem.&lt;/p&gt;

</description>
      <category>mulesoft</category>
      <category>anypoint</category>
      <category>cloudhub</category>
    </item>
    <item>
      <title>How to Set HTTP Error Responses in MUnit Testing</title>
      <dc:creator>Takahiro Yamamoto</dc:creator>
      <pubDate>Mon, 10 Jul 2023 11:18:08 +0000</pubDate>
      <link>https://dev.to/yamamo/how-to-set-http-error-responses-in-munit-testing-44gk</link>
      <guid>https://dev.to/yamamo/how-to-set-http-error-responses-in-munit-testing-44gk</guid>
      <description>&lt;p&gt;The development of efficient and robust MuleSoft applications requires comprehensive unit testing, and MUnit is an invaluable tool for this purpose. In this blog post, we'll delve into some tips for handling error status returned from the 'HTTP Request' backend during unit testing.&lt;/p&gt;

&lt;p&gt;When we have logic that branches based on the contents of the response, the unit testing approach becomes a bit more intricate. The response body of the error status returned from the backend is stored in 'error.errorMessage.payload'. In typical situations, you might want to directly assign a value to this field using 'Mock when'. However, 'Mock when' doesn't allow you to set a value to 'error.errorMessage.payload'.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4e9Xheq5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ig6y5384sd1z9kml1309.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4e9Xheq5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ig6y5384sd1z9kml1309.png" alt="Image description" width="800" height="582"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, how do we work around this limitation? Here comes the 'Then Call' to the rescue. In the subflow called by 'Then Call', you can use the 'Set Event' to establish an exception. This way, you're able to mimic the desired behavior by setting the 'error.errorMessage.payload' as part of the flow.&lt;/p&gt;

&lt;p&gt;The type of exception you're looking to set here should be an instance of the 'ResponseValidatorTypedException' class from Java. It accurately represents the sort of exception that would occur in a live environment when an error status is returned from the backend.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sPen8sIX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/krio96aq5hq46dki85yb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sPen8sIX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/krio96aq5hq46dki85yb.png" alt="Image description" width="800" height="489"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;%dw 2.0
output application/java

var detailMessage = 'Internal server error'
var errorType = java!org::mule::extension::http::api::error::HttpError::INTERNAL_SERVER_ERROR
---
java!org::mule::extension::http::api::request::validator::ResponseValidatorTypedException::new(detailMessage, errorType, message)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By leveraging this technique, you can achieve a more accurate and efficient unit testing process for your MuleSoft applications. It allows you to replicate the behavior of the 'HTTP Request' backend error status more accurately in your tests, ensuring that your code is capable of handling such scenarios in real-world operations.&lt;/p&gt;

&lt;p&gt;Remember, comprehensive unit testing is a crucial aspect of creating reliable and robust MuleSoft applications. Therefore, understanding how to handle and mimic different error statuses during testing can significantly enhance your application's quality and reliability.&lt;/p&gt;

&lt;p&gt;In conclusion, unit testing with MUnit in MuleSoft Applications might appear challenging, but with the right approach and understanding, it can be manageable and effective. Hopefully, this post has offered you some useful insights into this topic. Happy testing!&lt;/p&gt;

</description>
      <category>mulesoft</category>
      <category>anypoint</category>
    </item>
    <item>
      <title>Leverage Exchange Mocking Service with Mocking Service Proxy</title>
      <dc:creator>Takahiro Yamamoto</dc:creator>
      <pubDate>Mon, 22 May 2023 10:54:26 +0000</pubDate>
      <link>https://dev.to/yamamo/leverage-exchange-mocking-service-with-mocking-service-proxy-2cp4</link>
      <guid>https://dev.to/yamamo/leverage-exchange-mocking-service-with-mocking-service-proxy-2cp4</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Anypoint Exchange's Mocking Service is a powerful tool that provides real-time feedback during the API design process.&lt;br&gt;
This article discusses the ways to use the Mocking Service, its drawbacks, and the proposal of the Mocking Service Proxy as a solution to these challenges.&lt;/p&gt;

&lt;h2&gt;
  
  
  Accessing the Mocking Service
&lt;/h2&gt;

&lt;p&gt;Access to the Mocking Service from application essentially comes in two forms - public and private.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Public&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Mocking Service for assets published in Public Portals can be called without authentication.&lt;br&gt;
However, the downside of this approach is the potential exposure of the API specification to external parties.&lt;br&gt;
Therefore, this option needs careful consideration when security is critical.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XPTezMQc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yg3rrjf4syf1kgk5z7um.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XPTezMQc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yg3rrjf4syf1kgk5z7um.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Private&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On the other hand, In the case of not publishing to Public Portals, access to the Mocking Service is limited to a specific set of users or groups.&lt;br&gt;
However, this method requires implementing an additional program to obtain an access token from the Anypoint Platform.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7845Eusu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/87hmgm8adlvp9p21s21k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7845Eusu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/87hmgm8adlvp9p21s21k.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Proposal of Mocking Service Proxy
&lt;/h2&gt;

&lt;p&gt;As a solution to these issues, we propose the creation of a Mocking Service Proxy.&lt;br&gt;
This Proxy encapsulates the process of obtaining the access token and allows usage with regular API authentication methods such as Client ID and Client Secret.&lt;/p&gt;

&lt;p&gt;A major benefit of this approach is the ability to utilize the Mocking Service without exposing the API specifications and eliminating the manual process of obtaining the access token.&lt;br&gt;
This allows developers to focus on make an application that call the API.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7XV9au-W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kq7yd36nbid64p0qitwx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7XV9au-W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kq7yd36nbid64p0qitwx.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Mechanism of Mocking Service Proxy
&lt;/h2&gt;

&lt;p&gt;The Mocking Service Proxy is based on the Endpoint with Proxy Mule application, which is generated through the API Manager.&lt;br&gt;
The standard operation of the Endpoint with Proxy Mule application is to route the incoming API calls to the appropriate endpoints.&lt;/p&gt;

&lt;p&gt;Before routing the API calls, the Mocking Service Proxy executes a process to obtain an access token from the Anypoint Platform.&lt;br&gt;
This process encapsulates the client authentication method - using Connected App - and uses this information to request an access token from Anypoint Platform's authorization server.&lt;/p&gt;

&lt;p&gt;Once the access token is obtained, it is attached to the API call as a token in the MS2-Authorization header.&lt;br&gt;
Following this, the API call is routed to the appropriate endpoint, just as in the normal operation of the Endpoint with Proxy Mule application.&lt;/p&gt;

&lt;p&gt;Now comes the decision-making process for routing. The Mocking Service Proxy determines which Mocking Service asset to call based on the first path segment. For instance, if the API request is /asset1/data, the Mocking Service for asset1 will be called.&lt;br&gt;
This design allows efficient routing and ensures that the appropriate Mocking Service is called for each request.&lt;/p&gt;

&lt;p&gt;Other approaches can also be considered for determining the Mocking Service to be used, such as determining based on HTTP header or setting up a Proxy for each asset. However, the first path segment-based approach provides a simple and effective solution that balances flexibility and complexity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefit
&lt;/h2&gt;

&lt;p&gt;One significant advantage of using the Mocking Service Proxy is its ability to bridge the gap between calling a Mocking Service and a implemented API endpoint.&lt;/p&gt;

&lt;p&gt;For example, a implemented API endpoint require authentication using a Client ID and Client Secret.&lt;br&gt;
On the other hand, a Exchange Mocking Service not require these authentication steps or has dedicated authentication steps.&lt;/p&gt;

&lt;p&gt;The Mocking Service Proxy addresses this issue by encapsulating the authentication of Exchange Mocking Service process within its workflow. Requiring no additional steps from the developers.&lt;/p&gt;

&lt;p&gt;In this way, the Mocking Service Proxy enables a seamless transition between the development and production environments. It allows developers to focus on the core aspects of their work - designing and implementing the API - without worrying about the intricacies of the authentication process and environmental discrepancies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sample Implementation
&lt;/h2&gt;

&lt;p&gt;I have created a sample implementation that can be used as a reference.&lt;br&gt;
You can find the sample implementation &lt;a href="https://github.com/yamamoWorks/mocking-service-proxy"&gt;here&lt;/a&gt;. Please note that you may need to adjust the implementation to suit the specific needs and requirements of your project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;While the Mocking Service is an excellent tool for rapid feedback during the API design phase, its usage comes with certain challenges.&lt;br&gt;
By leveraging the Mocking Service Proxy, these challenges can be addressed, making the development process more efficient.&lt;/p&gt;

&lt;p&gt;The Mocking Service Proxy encapsulates the process of obtaining access tokens.&lt;br&gt;
This allows developers to focus on application that call the API development.&lt;/p&gt;

</description>
      <category>mulesoft</category>
      <category>anypoint</category>
    </item>
    <item>
      <title>Custom Alerts and Notifications in CloudHub 2.0</title>
      <dc:creator>Takahiro Yamamoto</dc:creator>
      <pubDate>Tue, 22 Nov 2022 10:37:46 +0000</pubDate>
      <link>https://dev.to/yamamo/custom-alerts-and-notifications-in-cloudhub-20-i77</link>
      <guid>https://dev.to/yamamo/custom-alerts-and-notifications-in-cloudhub-20-i77</guid>
      <description>&lt;p&gt;In the case of using CloudHub 1.0, Custom alerts and notifications are often used in the Non-API application (i.g. Scheduler, MQ listener) for error notification.&lt;/p&gt;

&lt;p&gt;Unfortunately, CloudHub 2.0 does not support custom notifications for now.&lt;br&gt;
&lt;a href="https://docs.mulesoft.com/cloudhub-2/ch2-comparison#application-considerations"&gt;CloudHub 2.0 for CloudHub 1.0 Users | MuleSoft Documentation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UX7pFjwj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l24zaw3ra8gkxdl629p8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UX7pFjwj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l24zaw3ra8gkxdl629p8.png" alt="Image description" width="806" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We need to consider alternatives, in using CloudHub 2.0.&lt;br&gt;
Sending an email directly using an Email connector and Amazon SES may be one workaround, but it depends on external service.&lt;br&gt;
And I’d rather not change the architecture from the current.&lt;/p&gt;

&lt;p&gt;I believe to be supported some notification function in CloudHub 2.0 near future.&lt;br&gt;
I came up with an interim measure until that is implemented.&lt;/p&gt;

&lt;p&gt;It's so simple, using custom notifications on CloudHub 1.0 in CloudHub 2.0.&lt;/p&gt;

&lt;p&gt;Create empty application and deploy it to CloudHub 1.0, it called 'customer-papi-alert', and stop it. (save vCores)&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_UXcht-l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0sar6pya8fkav99s6ohb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_UXcht-l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0sar6pya8fkav99s6ohb.png" alt="Image description" width="880" height="263"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And set the alerts on 'customer-papi-alert'.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pT8dDEgV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wk6epnwrebbbns70t2zw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pT8dDEgV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wk6epnwrebbbns70t2zw.png" alt="Image description" width="875" height="746"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create real application and deploy it to CloudHub 2.0, it called 'customer-papi'.&lt;br&gt;
The domain field of 'Create Notification' is 'customer-papi-&lt;strong&gt;alert&lt;/strong&gt;'.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8i4n1lOa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cv8lsp4zfq6vpz1p7k7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8i4n1lOa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cv8lsp4zfq6vpz1p7k7.png" alt="Image description" width="880" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The illustrate for behavior.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--40yHaSjY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocfc7mgknti90hbvm7bj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--40yHaSjY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocfc7mgknti90hbvm7bj.png" alt="Image description" width="880" height="733"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it.&lt;/p&gt;

</description>
      <category>mulesoft</category>
      <category>cloudhub</category>
      <category>anypoint</category>
    </item>
  </channel>
</rss>
