Refactor XML response handling in device extended and security tests

- Adjusted formatting in XML response strings for consistency in device_extended_test.go and device_security_test.go.
- Improved readability by aligning XML declaration and body content.
- Updated mock server responses to ensure proper handling of various ONVIF operations.

Enhance device security and storage handling

- Refactored struct field declarations in device_security.go and device_storage_test.go for improved clarity.
- Ensured consistent formatting across struct definitions and XML tags.

Standardize whitespace and formatting across multiple files

- Removed unnecessary blank lines and adjusted indentation in discovery, imaging, media, and PTZ server files.
- Improved overall code readability and maintainability by ensuring consistent formatting.

Update example applications for better readability

- Cleaned up whitespace in example applications to enhance code clarity.
- Ensured consistent formatting in main.go files across various examples.

Refactor server and SOAP handler code for consistency

- Standardized struct field declarations and XML tag formatting in server and SOAP handler files.
- Improved readability by aligning struct fields and ensuring consistent use of whitespace.

General code cleanup and formatting adjustments

- Applied consistent formatting across various files, including types.go and test files.
- Enhanced readability by aligning struct fields and removing unnecessary blank lines.
This commit is contained in:
ProtoTess
2025-12-01 00:49:36 +00:00
parent 856f49c82d
commit b4e4982876
37 changed files with 318 additions and 322 deletions
+10 -10
View File
@@ -24,7 +24,7 @@ func newMockDeviceExtendedServer() *httptest.Server {
switch {
case strings.Contains(bodyContent, "AddScopes"):
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<tds:AddScopesResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl"/>
@@ -32,7 +32,7 @@ func newMockDeviceExtendedServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "RemoveScopes"):
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<tds:RemoveScopesResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
@@ -42,7 +42,7 @@ func newMockDeviceExtendedServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "SetScopes"):
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<tds:SetScopesResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl"/>
@@ -50,7 +50,7 @@ func newMockDeviceExtendedServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "GetRelayOutputs"):
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<tds:GetRelayOutputsResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
@@ -66,7 +66,7 @@ func newMockDeviceExtendedServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "SetRelayOutputSettings"):
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<tds:SetRelayOutputSettingsResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl"/>
@@ -74,7 +74,7 @@ func newMockDeviceExtendedServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "SetRelayOutputState"):
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<tds:SetRelayOutputStateResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl"/>
@@ -82,7 +82,7 @@ func newMockDeviceExtendedServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "SendAuxiliaryCommand"):
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<tds:SendAuxiliaryCommandResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
@@ -92,7 +92,7 @@ func newMockDeviceExtendedServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "GetSystemLog"):
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<tds:GetSystemLogResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
@@ -104,7 +104,7 @@ func newMockDeviceExtendedServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "SetSystemFactoryDefault"):
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<tds:SetSystemFactoryDefaultResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl"/>
@@ -112,7 +112,7 @@ func newMockDeviceExtendedServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "StartFirmwareUpgrade"):
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<tds:StartFirmwareUpgradeResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl">