Metadata-Version: 2.4
Name: soap-failover-proxy
Version: 2.0.2
Summary: Dynamic failover proxy routing middleware for SOAP and WSGI web services
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: cryptography>=42.0.0

# SOAP FAILOVER PROXY

## 1.0 Administration

### 1.1 CHANGE LOG

```text
|Version | Date        | Author   | Description   |
|--------|-------------|----------|---------------|
| 1.0    | 11 Oct 2026 | Sarna, J.| First Draft   |
```

## 2.0 DESCRIPTION 
When compiled into an assembly and imported by SOAP webservices, allows dynamic reconfiguration.

The application uses Python 3.12.1. It was designed to work with Spyne SOAP Python Servers, but can work with REST Python Servers too. Packages have been frozen in requirements.txt via cmd 'pip freeze > requirements.txt'


### 3.1 How to install

#### 3.1.1 LOCAL

##### 3.1.1.1 Create Assembly

###### When adding new version
Once, I changed the version to 2.0.0. Even, when 'pip install -e .' passes, the package could not be located (cmd 'python -c "import soap_failover_proxy; print('SUCCESS!')"' failed). 

This was resolved via running a Force clean reinstall of local folder:

```bash
pip install -e . --force-reinstall
```

##### 3.1.1.2 Unit test the assembly process:

```bash
(venv) C:\Users\moose\eclipse-workspace\transliteration.systematicdefence.tech>python -c "import soap_failover_proxy; print('Transliteration app successfully grabbed it!')"
Transliteration app successfully grabbed it!
```



### 3.2 HOW to Test


#### 3.2.1 Import into webservice, which has a like for like duplicate/backup

Since, the folder holding the webservice, and the soap-service is different, provide location:

```bash

C:\Users\moose\eclipse-workspace\transliteration.systematicdefence.tech>venv\Scripts\activate

(venv) C:\Users\moose\eclipse-workspace\transliteration.systematicdefence.tech>pip install -e ../../eclipse-my-workspace/Soap-failover-proxy/. --force-reinstall
Obtaining file:///C:/Users/moose/eclipse-my-workspace/Soap-failover-proxy
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Requirement already satisfied: cryptography>=42.0.0 in c:\users\moose\eclipse-workspace\transliteration.systematicdefence.tech\venv\lib\site-packages (from soap-failover-proxy==2.0.1) (50.0.2)
Requirement already satisfied: cffi>=2.0.0 in c:\users\moose\eclipse-workspace\transliteration.systematicdefence.tech\venv\lib\site-packages (from cryptography>=42.0.0->soap-failover-proxy==2.0.1) (2.1.1)
Requirement already satisfied: pycparser in c:\users\moose\eclipse-workspace\transliteration.systematicdefence.tech\venv\lib\site-packages (from cffi>=2.0.0->cryptography>=42.0.0->soap-failover-proxy==2.0.1) (3.11)
Building wheels for collected packages: soap-failover-proxy
  Building editable for soap-failover-proxy (pyproject.toml) ... done
  Created wheel for soap-failover-proxy: filename=soap_failover_proxy-2.0.1-0.editable-py3-none-any.whl size=3178 sha256=48dfe3a350343c2023b89d64c16c58d13f5ce65af12ec2f3017ecd7f0f212b0c
  Stored in directory: C:\Users\moose\AppData\Local\Temp\pip-ephem-wheel-cache-11lhnhsp\wheels\7d\21\47\83dbedb8aef8b572caa0e369eca420685dfe13015ff98b7cc6
Successfully built soap-failover-proxy
Installing collected packages: soap-failover-proxy
  Attempting uninstall: soap-failover-proxy
    Found existing installation: soap-failover-proxy 2.0.0
    Uninstalling soap-failover-proxy-2.0.0:
      Successfully uninstalled soap-failover-proxy-2.0.0
Successfully installed soap-failover-proxy-2.0.1

[notice] A new release of pip is available: 24.0 -> 26.2.2
[notice] To update, run: python.exe -m pip install --upgrade pip

(venv) C:\Users\moose\eclipse-workspace\transliteration.systematicdefence.tech>python -c "import soap_failover_proxy; print('Transliteration app successfully grabbed it')"
Transliteration app successfully grabbed it

```

#### 3.2.2 Add vendor supplied 'ecryption key' and 'admin key' to webservice's .env

```text
ADMIN_API_KEY=<redacted>
MY_AES_SECRET_KEY=<redacted>
```

#### 3.2.3 Create encrypted string

![Create encrypted string as admin key](./CustomerKeyGenTool.png)  


#### 3.2.4 Ensure both candidate web services are turned on

##### 3.2.4.1 Calc Webservice

```bash
C:\Users\moose\eclipse-workspace\transliteration.systematicdefence.tech>rmdir /s /q venv

C:\Users\moose\eclipse-workspace\transliteration.systematicdefence.tech>py -3.11 -m venv venv

C:\Users\moose\eclipse-workspace\transliteration.systematicdefence.tech>venv\Scripts\activate

(venv) C:\Users\moose\eclipse-workspace\transliteration.systematicdefence.tech>pip install -r requirements.txt

(venv) C:\Users\moose\eclipse-workspace\transliteration.systematicdefence.tech>waitress-serve --host=127.0.0.1 --port=8000 passenger_wsgi:application
INFO:waitress:Serving on http://127.0.0.1:8000

```

##### 3.2.4.2 Calc Backup Webservice

```bash
(venv) C:\Users\moose\eclipse-workspace\transliteration-backup.systematicdefence.tech>waitress-serve --host=127.0.0.1 --port=8080 passenger_wsgi:application
INFO:waitress:Serving on http://127.0.0.1:8080
```

#### 3.2.5 Make Request
 
##### 3.2.5.1  Switch to backup

![SWITCH_TO_BACKUP](./SWITCH_TO_BACKUP_WORKS.png) 

##### 3.2.5.2 Switch from backup

![SWITCH_TO_LOCAL](./SWITCH_TO_LOCAL_WORKS.png) 

## Versions

### Version 1.0 Operational 

11 Oct 2026 Sunday 15:43

See tests/EndtoEndSmokeTest.md and tests/UnitTests.md for current functionality.

### Version 1.0.1 Post Quantum protection added
11 Oct 2026 Sunday 16:59

Added Shared Secret to keep Admin key protected from Post Quantam attacks. Updated tests.

### Version 2.0.0 Post Quantum protection tests pass

11 Oct 2026 Sunday 18:22

Post Quantum protection and dependency in assembly. See test/UnitTests.md for evidence.

### Version 2.0.1 Add facility of testing endpoint, when all service endpoints redirected

24 Oct 2026 Sunday 17:00

Now the assembly provides facility to enable testing even when it is being redirected to backup. It does so via a token it generates at runtime. This needs to be provided to the webservice in the header. This token is stored in Maintenance.lock, and is returned as part of the 'switch-to-backup' method. Unit Tests all pass. See UnitTests.md for details. Here is an example

```bash
PS C:\Users\moose> curl -X POST http://127.0.0.1:8000/ `
>>     -H "Content-Type: text/xml; charset=utf-8" `
>>     -H "X-BYPASS-TOKEN: 3698e1add5287563cd4c03e06da9ce37" `
>>     -d $xmlData
<?xml version='1.0' encoding='UTF-8'?>
<soap11env:Envelope xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="spyne.examples.hello"><soap11env:Body><tns:add_numbersResponse><tns:add_numbersResult>12</tns:add_numbersResult></tns:add_numbersResponse></soap11env:Body></soap11env:Envelope>
```

### Version 2.0.2 Updated to ensure that incorrect header provided for testing endpoint is handled gracefully 

29 Oct 2026 Thursday 21:30

Negative scenario setup to ensure test url:

```bash
PS C:\Users\moose> curl -X POST http://127.0.0.1:8000/ `
>>     -H "Content-Type: text/xml; charset=utf-8" `
>>     -H "X-BYPASS-TOKEN: asd" `
>>     -d $xmlData
403 Forbidden: Invalid maintenance bypass token validation parameter.
```
