PHP / Laravel and Jenkins - php

I'm Integrating Laravel and Jenkins, and it seems to be working.
The only problem I have is that all my tests are used with base Url : http://localhost.
So All my tests fails because it says:
http://**localhost**/path/to/uri] failed. Received status code [500].
So, all the test fails because I guess I don't know
Where should I define what should be the http://localhost to be the baseUrl I want.
What should I put here, or where should I configure it... I could log ssh to my Jenkins machine and curl my url to see what's the response to see if it is responding well, but I'm quite unsure how should this work...
Any help will be appreciated!

Open TestCase.php which is inside test folder. There you should have protected $baseUrl which should be your application URL.

Related

Shopify: There’s no page at this address Check the URL and try again, or use the search bar to find what you need

I’m new to Shopify App development. I’ve developed an app using a php template provided by shopify. It’s using Laravel & React. It’s https://github.com/Shopify/shopify-app-template-php/tree/cli_three
When I execute npm run dev, the app is running in the development store.
Then, I deployed my app on the AWS server using one domain (e.g: sub.mydomain.com).
Before deployment:
I have build the frontend using: SHOPIFY_API_KEY=MY_API_KEY npm run build
I’ve run composer build too.
After that, I tried to install the app. While doing so, It’s authenticating and saving the session in the database too.
But, on redirecting after authentication, it’s not working,
First, It’s giving this error on console:
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://mystore.myshopify.com') does not match the recipient window's origin ('https://sub.mydomain.net').
And then after redirect, it’s displaying:
Along with console error:
GET https://mystore.myshopify.com/admin/apps/40aac89c4c56232219d0f1f75a1f2ae7/?hmac=68236dae6688aafd05925cf409dfff0965236542401999f8ff47decd8b942d&host=cW9kZWFuYWx5dGljcy5JKihgZnkuY29tL2FkbWlu&shop=mystore.myshopify.com&timestamp=1657698129 404
About that console error you need to add this header on top of the page in views top_level.blade.php
<?php
$domain= $shop ?? Auth::user()->name ; ; // loged-in shopify store url example.myshopify.com
header("Content-Security-Policy: frame-ancestors https://".$domain." "."https://admin.shopify.com");
?>
This will resolve the does not match the recipient window's origin error.
After that try to open the app again or you can remove the entry from db and install the app again hope that will help.

AWS Laravel Unit Testing - The security token included in the request is invalid

I am doing unit testing for my AWS Cloudfront code using phpunit, if I am not testing the code in the command line, my code works perfectly fine. But if I am testing it in the command line, I am getting this error: The security token included in the request is invalid. I read somewhere that i need to work on Laravel "mock", but I can't seem to make that work.
Here is my code:
$this->instance(CloudFrontService::class, \Mockery::mock(CloudFrontService::class, function ($mock) {
$mock->shouldReceive('invalidate')->with("test.txt")->once();
}));
$r = app(CloudFrontService::class)->invalidate("test.txt");
$this->assertTrue($r);
Any guidance is greatly appreciated. Thank you!

Wordpress REST API Issue

I'm currently trying to wrap my head around Wordpress and its relation to the REST API. All of theses issues are only occurring in the context of plugin development. So far I had setup my endpoint and written my callback which will be executed whenever someone is sending a GET-Request to said endpoint. However, my callback is never called. This is the file which I've written so far.
/*
* Plugin Name: cola-learning
*/
if(!defined('ABSPATH')){
die;
}
if(!function_exists('add_action')){
echo 'You cant access this ressource!';
exit;
}
function PrintRESTResponse()
{
return rest_ensure_response("student");
}
function SetupREST()
{
return register_rest_route("student/v1","/view/",[
'methods' => 'GET',
'callback' => 'PrintRESTResponse'
],false);
}
add_action('rest_api_init','SetupREST');
Perhaps it might also help, if I'll give some background information about my development machine:
- OS: Windows 10
- Server: Apache Web Server (included inside XAMPP)
- Wordpress Version: 5.3.2
- PHP Version: 7.4
- Development IDE: Eclipse 2019-12 CDT ( with PHP Plugin )
From my research, everything should work fine. However, it doesnt :/ Did I miss something crucial?
Update:
WordPress REST API Routing
WordPress is having a default route for all request which are directed to the REST API ( at least if you use XAMPP with the Bitnami WordPress application module). Now, if one wants to send a request to said REST API, the person needs to use an URL with the form of ip:port/wp-json/rest_route. ip ressembles the ip address of the server which is hosting wordpress. port is the port of said server. wp-json, however, is the portion which differs an ordinary request from a request to the REST API. Everything after this portion (rest_route) is the rest route which I've defined in the above source code.
What went wrong?
My request was pointed to the wrong endpoint. Therefore I used the URL 'localhost:wpPort/wordpress/student/v1/view/'. However, the 'wp-json/' portion is missing. Therefore WordPress will search for a page that doesn't exist in the first place. Instead I should have used the URL 'localhost:wpPort/wordpress/wp-json/student/v1/view/'.
After some troubleshooting it turns out the URL being used to test was missing a part of the endpoint path.
Here is the correct path to test the newly registered endpoint.
localhost:80/wordpress/wp-json/student/v1/view/
Here's some more reading on WP Rest API endpoints:
https://developer.wordpress.org/rest-api/extending-the-rest-api/routes-and-endpoints/

CakePHP : REST API 404 Error

I have build a REST server and trying to make my java application communicate to it.
But I keep getting a 404 error.
When I type in the url in my browser along with the function name like:
[url]/controller/functionname/1.json
it works fine, returning me the right data.
Without the function name:
[url]/controller/1.json
I get this error:
"action 1.json not defined in controller".
I've checked my .htaccess file and routes against a previous version I had build which was working just fine. I can't figure out what the problem might be. Any suggestions?
And oh, I should mention, the earlier version that I talked about was build on windows and this one on ubuntu.

Zend Soap Server with wsdl - 403 Forbidden

I'm working on a project with ZF in windows environment (using wamp) trying to develop a web service (wsdl definition) with the Soap library of Zend.
Everything works as expected at localhost, the URI http://localhost/mySite/webService/Server.php?wsdl returns a good definition of the service and it can be consumed. But the same using an IP like, let's say http://192.168.1.20/mySite/webService/Server.php?wsdl doesn't seem to be available. I get the error:
Forbidden
You don't have permission to access /mySite/webService/Server.php on this server.
I did the test using http://192.168.0.20/mySite/public/ and it works fine. I get the standard "Welcome to the Zend Framework!" because I haven't changed it yet (it even works using my public IP). In the same project I have some controllers/actions and they fail the same way.
I think the problem could be related with the httpd.conf file, but I don't really know how to handle it. Or maybe the .htaccess on this project?
Has somebody a clue?
Thanks.
Try without cache in your client:
$options['cache_wsdl'] = WSDL_CACHE_NONE:
$uri = http://192.168.1.20/mySite/webService/Server.php?wsdl;
$client = new Zend_Soap_Client($uri, $options);

Categories