Thursday, October 31, 2019

How to build SOAP mock service using SOAP UI

Here I have described step by step guidelines to create SOAP mock service using SOAP UI

Prerequisites:

  • SOAP UI
  • Simple SOAP WS (we are going to mock this service)
STEP 01:

Right click on your SOAP project interface and go to "Generate SOAP Mock Service"


STEP 02:
 Here you can design your mock service. eg: path, port, operation, etc And then click OK.


 STEP 03:

Your MOCK service has been created. Now you can define the response as below.


 STEP 04:

 Once updated, you can start the MOCK service.


 STEP 05:

 Now your MOCK service is running on given port


 STEP 06:

 Now you can trigger MOCK service using SOAP UI and see the configured response.


 STEP 07:

 You can see the log in start window as well.




Friday, September 6, 2019

Find if a SSL certificate is self signed or CA signed

Try below command for .pem certificate file

       
openssl x509 -in certificate.pem -inform PEM -noout -subject -issuer
       

If subject and issuer are same : It is self signed certificate
If subject and issuer are different : It is CA signed certificate and issuer will be CA

Tuesday, April 16, 2019

How to remove ssh-agent process in redhat


When you log out, you want the ssh-agent process to be terminated automatically.

You can add below command in .bash_profile file

trap 'test -n "$SSH_AGENT_PID" && eval `/usr/bin/ssh-agent -k`' 0

If you need to remove existing processes,

for(( ; ; )); do kill $(ps -ef | grep ssh-agent | grep -v grep  | grep -v grep | awk -F' ' '{print($2)}' | head -1 );echo "done"; done


Friday, April 5, 2019

Mysql Load Balancing with Nginx (Ubuntu)


Environment setup:

Mysql master server : 192.168.1.10
Mysql slave server : 192.168.1.12

Nginx server : 192.168.1.14

1. Add Nginx configurations

Add below configuration to nginx main configuration file (/etc/nginx/nginx.conf) just after the http block     
stream {
    upstream mysql_cluster {
        server 192.168.1.10:3306; # node1
        server 192.168.1.12:3306 backup; # node2
    }
    server {
        listen 3306; 
        proxy_pass mysql_cluster;
    }
}
2. Open 3306 port in Nginx server

Since we are using 3306 port, we need to use SELinux and open port privileges
Try below command in Nginx server
sudo semanage port -l | grep http_port_t
check port 3306 is there, if not we can add it by using below command
sudo semanage port -a -t http_port_t  -p tcp 3306 
3. Enable firewall

 If you are using CentOS, you may use below command to enable firewall rules in Nginx server

firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload

Sunday, November 4, 2018

Import SSH private key file to Xshell

Once you generate SSH key pair to connect to a server using putty and you are going to import it into Xshell you will be noticed below notification.













You can follow below steps to import ssh private key to Xshell successfully.

  1. Open putty-keygen and import the private key.


















2. Once loaded, Go to "Conversions" and then "Export OpenSSH Key"




















3. Then choose a location to save the private key file and click "Save".

4. You will be able to import above private key file to Xshell.

Monday, August 13, 2018

Simple HTTP Listener using Python

Here is a simple HTTP listener using Python BaseHTTPRequestHandler 
This Application will,

  • listen to port 8000 on localhost
  • respond to REST POST request 

from BaseHTTPServer import BaseHTTPRequestHandler
import urlparse, json
import shutil
import os

class GetHandler(BaseHTTPRequestHandler):

	def do_POST(self):

		content_len = int(self.headers.getheader('content-length'))
		req_token = self.headers.get('Authorization')
		post_body = self.rfile.read(content_len)
		data = json.loads(post_body)
		user_id = data['id']
		user_name = data['name']
		
		print ("Token "+str(req_token))
		print ("User Id "+str(user_id))
		print ("User Name "+str(user_name))
		 
		#Do something here
		
		self.send_response(200)
		return

if __name__ == '__main__':
	from BaseHTTPServer import HTTPServer
	server = HTTPServer(('localhost', 8000), GetHandler)
	print 'Starting server at http://localhost:8009'
	server.serve_forever()

    
 
Save the content as simple_http_server.py

Start Application : python simple_http_server.py

Sample Request:

curl -v -X POST -H 'Authorization: Bearer gcfdgckuyebku7t56FHGVBKJHKJTY6' -d '{"id":"1234","name":"Hasitha"}' http://localhost:8000

Sample Response:

* Rebuilt URL to: http://localhost:8000/
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> POST / HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.47.0
> Accept: */*
> Authorization: Bearer gcfdgckuyebku7t56FHGVBKJHKJTY6
> Content-Length: 30
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 30 out of 30 bytes
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.3 Python/2.7.12
< Date: Mon, 13 Aug 2018 15:21:06 GMT

* Closing connection 0

Application Logs:

Starting server at http://localhost:8000
Token Bearer gcfdgckuyebku7t56FHGVBKJHKJTY6
User Id 1234
User Name Hasitha

127.0.0.1 - - [13/Aug/2018 15:21:06] "POST / HTTP/1.1" 200 -







File Sharing using NFS in GKE Cluster

 File Sharing using NFS in GKE Cluster There was a requirement to create common file sharing location which should be accessible by specific...