Testing Rails+Webhooks with Cucumber - ruby-on-rails

I'm trying to integrate my rails application with an external service. I'm using Cucumber to do integration testing and I'd don't want to mock out the external service at times. When I get webhooks from this service, they are routed to apache running my development environment. This would be easy to fix if I could figure out how to fixate my cucumber rails process on a particular port or how to proxy to it.
Basically, how do I get external webhooks (POSTs) routed to my cucumber rails process while it's running?

It appears that this is possible with Selenium as it starts a webserver on a configurable port.
I contacted the author of this blog post and he confirmed that he was using Selenium configured on the port he forwarded with localtunnel.

Related

Identity Server 4 in Docker using OIDC and Selenium Testing

I am currently trying to run an integration test with Selenium on the following setup:
IdentityServer4 hosted in a net core 3.1 REST service - running in its own docker container (securityservice)
MVC Test Web User Interface running under net core 3.1 - running in its own docker container (testuserinterface)
The selenium test is running on my local pc under a net core 3.1 test project
Where I am getting the issue is when i attempt to access a secure page on the Web Application the redirect is attempted to the identity server to show the user login page, however the url that the redirect is setup with id that of the docker container (e.g. http://securityservice/accouunt/login). This url is not accessible from my local browser so my test is failing locally.
Is there a way that the login url can be customised (only for test purposes) to be that of the local machine and the locally exposed docker port (e.g. http://127.0.0.1:dockerport/account/login).
I have tried many different examples and combinations with currently no success.
Any help in this area would be most appreciated.
Thanks in advance,
Stuart
What I have done for local development and testing in some cases is to create a local HTTPS certificate using mkcert and then in my local host file add an entry to map the domain of the certificate to 127.0.0.1
So I can use urls like https://identityservice:6001 to point to my IdentityServer.

How to deploy a Ruby on Rails app to AWS-EC2 Ubuntu Linux using Apache 2?

We want to configure Apache to work with a Rails app. We want Apache to do load control. We cannot get them to work together. We are using MySQL for the database. If we could please have some type of instruction or tutorial to follow to be able to deploy our application in AWS-EC2, it will be greatly appreciated.
We have a domain and we want to have multiple Rails app running in the same domain. Each rails app seems to want to run in a different port. We do not want to expose port 80/443. Apache is managing the inbound request. My attempts to use the host file has not been successful.

Is one rails server per application?

I have two questions about rails server:
Do I have to start the server from within the application folder?
Is the server I started only for that application?
If they are true, this does not quite make sense to me, since why do I need to start multiple servers?
Or is there some kind of master configuration, so that one server can route to different applications? Is Capistrano for this purpose?
I'm going to assume you're talking about the rails server command, for running a local rails server to test your application, and that you're not talking about setting up a rails application on a remote server. Please mention if that is not the case.
Yes, you must execute rails server from within the root folder of your rails application.
Yes, the server you started is only for that application. It's a self-contained thing.
You should not need to start multiple servers. Even if you have multiple applications, you probably don't need to have more than one running at a time. So, you can shut down the rails server in one application (Ctrl-C) and then cd to your new application, and start a new rails server there with rails server.
If you do need to run two local rails applications at once, you can do so by running them on different ports. So, the first one, you can just execute rails server and it will make your site available at localhost:3000 (because port 3000 is the default port). The next one, you can specify a port other than 3000 - eg. rails server -p 3001 to get a rails app at localhost:3001.
Capistrano is for deploying your applications to a remote server, not for running them locally on your own computer. So, it is not relevant here. What you may be interested in is http://pow.cx/
Again, I've assumed you're talking about running your rails app locally on your own computer. If you're referring to deploying it to the internet on a server, then you can ignore this answer.

AngularJS frontend and Rails backend with AWS in Ubuntu

I would like to discuss about AngularJS and Ruby on Rails working together and deployed in AWS (Amazon Web Services).
So far, I have a development environment with an AngularJS frontend that sends request to a Ruby on Rails API backend. These both are two separate applications (they are in separated git repositories).
The AngularJS app is running in a Node.js server listening on one port, and Rails is running in a Webrick server listening on another port.
Although they work together, AngularJS is not physically integrated in the RoR app.
Now its time to deploy in production environment. For that, I will use an EC2 AWS instance (currently deploying using Elastic Beanstalk). As far as I understand, I can't have the same architecture here.
I would like to know your suggestions this point. Do you see any advantages or disadvantages?
Should I update my development environment, so the AngularJS app is integrated inside the RoR application (and deploy just one application)?
This is something I don't like, because I guess I have to modify many things.
On the other hand, is it possible to run both applications separately, the same way I do in development?
Can I install a node.js and a Unicorn or whichever server manually in production in the same instance?
I finally deployed with two separated applications as described above. The main difference is around the servers. My AngularJS frontend finally runs on an Nginx. And my Rails API is running on a Unicorn.

Deploying Apache Solr

I've been experimenting with Apache SOLR and I'm ready to integrate it with a rails application. However, I'd like to make sure I know how to deploy solr. I currently have the rails application deployed using passenger+nginx. Is it possible to deploy SOLR using nginx as well? If so, how would I do that? Otherwise, what is the preferred method of deployment? Thanks!
Solr needs to run in a Java EE application server. You can use Jetty or Tomcat. Nginx will act as a proxy via AJP or something simliar to forward all RESTless request to Solr. I haven't used my ajp with nginx but I have read about this. Essentially you will have a Java EE application server, Rails server, nginx, passenger and ajp proxy running all at the same time.
You can also setup a proxy pass and there is a tutorial here. Explore different options to see which one is bet for you.

Resources