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
+15 -15
View File
@@ -24,7 +24,7 @@ func newMockDeviceSecurityServer() *httptest.Server {
switch {
case strings.Contains(bodyContent, "GetRemoteUser"):
_, _ = 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:GetRemoteUserResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
@@ -38,7 +38,7 @@ func newMockDeviceSecurityServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "SetRemoteUser"):
_, _ = 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:SetRemoteUserResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl"/>
@@ -46,7 +46,7 @@ func newMockDeviceSecurityServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "GetIPAddressFilter"):
_, _ = 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:GetIPAddressFilterResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
@@ -61,10 +61,10 @@ func newMockDeviceSecurityServer() *httptest.Server {
</s:Body>
</s:Envelope>`))
case strings.Contains(bodyContent, "SetIPAddressFilter"),
strings.Contains(bodyContent, "AddIPAddressFilter"),
strings.Contains(bodyContent, "RemoveIPAddressFilter"):
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
case strings.Contains(bodyContent, "SetIPAddressFilter"),
strings.Contains(bodyContent, "AddIPAddressFilter"),
strings.Contains(bodyContent, "RemoveIPAddressFilter"):
_, _ = 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:SetIPAddressFilterResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl"/>
@@ -72,7 +72,7 @@ func newMockDeviceSecurityServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "GetZeroConfiguration"):
_, _ = 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:GetZeroConfigurationResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
@@ -86,7 +86,7 @@ func newMockDeviceSecurityServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "SetZeroConfiguration"):
_, _ = 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:SetZeroConfigurationResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl"/>
@@ -94,7 +94,7 @@ func newMockDeviceSecurityServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "GetPasswordComplexityConfiguration"):
_, _ = 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:GetPasswordComplexityConfigurationResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
@@ -109,7 +109,7 @@ func newMockDeviceSecurityServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "SetPasswordComplexityConfiguration"):
_, _ = 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:SetPasswordComplexityConfigurationResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl"/>
@@ -117,7 +117,7 @@ func newMockDeviceSecurityServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "GetPasswordHistoryConfiguration"):
_, _ = 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:GetPasswordHistoryConfigurationResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
@@ -128,7 +128,7 @@ func newMockDeviceSecurityServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "SetPasswordHistoryConfiguration"):
_, _ = 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:SetPasswordHistoryConfigurationResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl"/>
@@ -136,7 +136,7 @@ func newMockDeviceSecurityServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "GetAuthFailureWarningConfiguration"):
_, _ = 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:GetAuthFailureWarningConfigurationResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
@@ -148,7 +148,7 @@ func newMockDeviceSecurityServer() *httptest.Server {
</s:Envelope>`))
case strings.Contains(bodyContent, "SetAuthFailureWarningConfiguration"):
_, _ = 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:SetAuthFailureWarningConfigurationResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl"/>