From 37e35f318940c0365070e62804a4ad354cb4a9dd Mon Sep 17 00:00:00 2001 From: Cody Lee Date: Thu, 2 Jan 2025 11:20:36 -0600 Subject: [PATCH] fixes ubb and uci fakes, adds test to check this in the future, tldr do not create circular fake loops --- devices.go | 2 +- devices_test.go | 22 ++++ mocks/mock_client_test.go | 21 +++ ubb.go | 268 ++++++++++++++++++++------------------ ubb_test.go | 15 +++ uci.go | 164 +++++++++++------------ uci_test.go | 15 +++ 7 files changed, 295 insertions(+), 212 deletions(-) create mode 100644 devices_test.go create mode 100644 mocks/mock_client_test.go create mode 100644 ubb_test.go create mode 100644 uci_test.go diff --git a/devices.go b/devices.go index acfa11e..3d8c839 100644 --- a/devices.go +++ b/devices.go @@ -265,7 +265,7 @@ func (u *Unifi) unmarshalDevice(dev string, data json.RawMessage, v interface{}) json, err := data.MarshalJSON() u.DebugLog("Failed Payload: %s (marshal err: %v)", json, err) - u.DebugLog("The above payload can prove useful during torubleshooting when you open an Issue:") + u.DebugLog("The above payload can prove useful during troubleshooting when you open an Issue:") u.DebugLog("==- https://github.com/unifi-poller/unifi/issues/new -==") } diff --git a/devices_test.go b/devices_test.go new file mode 100644 index 0000000..1a62b31 --- /dev/null +++ b/devices_test.go @@ -0,0 +1,22 @@ +package unifi_test + +import ( + "github.com/brianvoe/gofakeit/v6" + "github.com/stretchr/testify/require" + "github.com/unpoller/unifi/v5" + "testing" +) + +func TestDevices(test *testing.T) { + d := unifi.Devices{} + err := gofakeit.Struct(&d) + require.NoError(test, err) + require.NotEmpty(test, d.UBBs) + require.NotEmpty(test, d.UCIs) + require.NotEmpty(test, d.PDUs) + require.NotEmpty(test, d.UAPs) + require.NotEmpty(test, d.USGs) + require.NotEmpty(test, d.UDMs) + require.NotEmpty(test, d.UXGs) + require.NotEmpty(test, d.USWs) +} diff --git a/mocks/mock_client_test.go b/mocks/mock_client_test.go new file mode 100644 index 0000000..bff35de --- /dev/null +++ b/mocks/mock_client_test.go @@ -0,0 +1,21 @@ +package mocks_test + +import ( + "github.com/stretchr/testify/require" + "github.com/unpoller/unifi/v5/mocks" + "testing" +) + +func TestMockUnifiClient(t *testing.T) { + m := mocks.NewMockUnifi() + devices, err := m.GetDevices(nil) + require.NoError(t, err) + require.NotEmpty(t, devices.UAPs) + require.NotEmpty(t, devices.USGs) + require.NotEmpty(t, devices.UDMs) + require.NotEmpty(t, devices.USWs) + require.NotEmpty(t, devices.PDUs) + require.NotEmpty(t, devices.UCIs) + require.NotEmpty(t, devices.UXGs) + require.NotEmpty(t, devices.UBBs) +} diff --git a/ubb.go b/ubb.go index 59860c7..50b847f 100644 --- a/ubb.go +++ b/ubb.go @@ -17,7 +17,7 @@ type Bb struct { Oid string `json:"oid"` Bb string `json:"bb"` Time FlexInt `json:"time"` - Datetime time.Time `json:"datetime"` + Datetime time.Time `fake:"{recent_time}" json:"datetime"` UserWifi0RxPackets FlexInt `json:"user-wifi0-rx_packets"` UserTerra2RxPackets FlexInt `json:"user-terra2-rx_packets"` UserRxPackets FlexInt `json:"user-rx_packets"` @@ -133,141 +133,151 @@ func (v *UBBStat) UnmarshalJSON(data []byte) error { return nil } +type AntennaTable struct { + Default FlexBool `json:"default"` + ID FlexInt `json:"id"` + Name FlexString `json:"name"` + Wifi0Gain FlexInt `json:"wifi0_gain"` + Wifi1Gain FlexInt `json:"wifi1_gain"` +} + type UBB struct { - SiteName string `json:"-"` - SourceName string `json:"-"` - site *Site - RequiredVersion string `json:"required_version"` - HasSpeaker FlexBool `json:"has_speaker"` - LicenseState string `json:"license_state"` - MeshStaVapEnabled FlexBool `json:"mesh_sta_vap_enabled"` - Type string `json:"type"` - SetupID string `json:"setup_id"` - HwCaps FlexInt `json:"hw_caps"` - RebootDuration FlexInt `json:"reboot_duration"` - ConfigNetwork *ConfigNetwork `json:"config_network"` - SyslogKey string `json:"syslog_key"` - Model string `json:"model"` - LcmTrackerEnabled FlexBool `json:"lcm_tracker_enabled"` - BandsteeringMode string `json:"bandsteering_mode"` - IP string `json:"ip"` - LastConnectionNetworkName string `json:"last_connection_network_name"` - UbbIsAp FlexBool `json:"ubb_is_ap"` - LedOverrideColor string `json:"led_override_color"` - Version string `json:"version"` - UnsupportedReason FlexInt `json:"unsupported_reason"` - AdoptionCompleted FlexBool `json:"adoption_completed"` - AnonID string `json:"anon_id"` - LastConnectionNetworkID string `json:"last_connection_network_id"` - CountryCode FlexInt `json:"country_code"` - WlangroupIDNa string `json:"wlangroup_id_na"` - UbbSsid string `json:"ubb_ssid"` - AntennaTable []any `json:"antenna_table"` - WifiCaps FlexInt `json:"wifi_caps"` - SiteID string `json:"site_id"` - AdoptedAt FlexInt `json:"adopted_at"` - Name string `json:"name"` - FwCaps FlexInt `json:"fw_caps"` - ID string `json:"_id"` - UbbBssid string `json:"ubb_bssid"` - MgmtNetworkID string `json:"mgmt_network_id"` - GatewayMac string `json:"gateway_mac"` - AtfEnabled FlexBool `json:"atf_enabled"` - RadioTable []*RadioTable `json:"radio_table"` - ConnectedAt FlexInt `json:"connected_at"` - TwoPhaseAdopt FlexBool `json:"two_phase_adopt"` - InformIP string `json:"inform_ip"` - Cfgversion string `json:"cfgversion"` - Mac string `json:"mac"` - ProvisionedAt FlexInt `json:"provisioned_at"` - InformURL string `json:"inform_url"` - EthernetTable []*EthernetTable `json:"ethernet_table"` - UpgradeDuration FlexInt `json:"upgrade_duration"` - Unsupported FlexBool `json:"unsupported"` - SysErrorCaps FlexInt `json:"sys_error_caps"` + AdoptableWhenUpgraded FlexBool `json:"adoptable_when_upgraded"` + Adopted FlexBool `json:"adopted"` + AdoptedAt FlexInt `json:"adopted_at"` + AdoptedByClient string `json:"adopted_by_client"` + AdoptionCompleted FlexBool `json:"adoption_completed"` + AnonID string `json:"anon_id"` + AntennaTable []AntennaTable `fakesize:"1" json:"antenna_table"` + Architecture string `json:"architecture"` + AtfEnabled FlexBool `json:"atf_enabled"` + BandsteeringMode string `json:"bandsteering_mode"` + Bytes FlexInt `json:"bytes"` + BytesD FlexInt `json:"bytes-d"` + BytesR FlexInt `json:"bytes-r"` + Cfgversion string `json:"cfgversion"` + ConfigNetwork *ConfigNetwork `json:"config_network"` + ConnectRequestIP string `json:"connect_request_ip"` + ConnectRequestPort string `json:"connect_request_port"` + ConnectedAt FlexInt `json:"connected_at"` + ConnectionNetworkID string `json:"connection_network_id"` + ConnectionNetworkName string `json:"connection_network_name"` + CountryCode FlexInt `json:"country_code"` + DeviceID string `json:"device_id"` + DisconnectedAt FlexInt `json:"disconnected_at"` + DisconnectionReason string `json:"disconnection_reason"` + DisplayableVersion string `json:"displayable_version"` + DownlinkLLDPMacs []LLDPTable `fakesize:"1" json:"downlink_lldp_macs"` + DownlinkTable []DownlinkTable `fakesize:"1" json:"downlink_table"` + EthernetTable []EthernetTable `fakesize:"1" json:"ethernet_table"` + FixedApAvailable FlexBool `json:"fixed_ap_available"` + FwCaps FlexInt `json:"fw_caps"` + GatewayMac string `json:"gateway_mac"` + GeneralTemperature FlexInt `json:"general_temperature"` + HasEth1 FlexBool `json:"has_eth1"` + HasFan FlexBool `json:"has_fan"` + HasSpeaker FlexBool `json:"has_speaker"` + HasTemperature FlexBool `json:"has_temperature"` + HashID string `json:"hash_id"` + HwCaps FlexInt `json:"hw_caps"` + ID string `json:"_id"` + IP string `json:"ip"` + InformIP string `json:"inform_ip"` + InformURL string `json:"inform_url"` + IsAccessPoint FlexBool `json:"is_access_point"` + Isolated FlexBool `json:"isolated"` + KernelVersion string `json:"kernel_version"` + KnownCfgversion string `json:"known_cfgversion"` + LastConnectionNetworkID string `json:"last_connection_network_id"` + LastConnectionNetworkName string `json:"last_connection_network_name"` + LastSeen FlexInt `json:"last_seen"` LastUplink struct { UplinkMac string `json:"uplink_mac"` UplinkRemotePort FlexInt `json:"uplink_remote_port"` PortIdx FlexInt `json:"port_idx"` Type string `json:"type"` } `json:"last_uplink"` - LedOverride string `json:"led_override"` - DisconnectedAt FlexInt `json:"disconnected_at"` - UbbPairName string `json:"ubb_pair_name"` - Architecture string `json:"architecture"` - XAesGcm FlexBool `json:"x_aes_gcm"` - HasFan FlexBool `json:"has_fan"` - HasEth1 FlexBool `json:"has_eth1"` - ModelIncompatible FlexBool `json:"model_incompatible"` - XAuthkey string `json:"x_authkey"` - ModelInEol FlexBool `json:"model_in_eol"` - HasTemperature FlexBool `json:"has_temperature"` - AdoptedByClient string `json:"adopted_by_client"` - ModelInLts FlexBool `json:"model_in_lts"` - UbbPairID string `json:"ubb_pair_id"` - KernelVersion string `json:"kernel_version"` - Serial string `json:"serial"` - UbbPsk string `json:"ubb_psk"` - FixedApAvailable FlexBool `json:"fixed_ap_available"` - LedOverrideColorBrightness FlexInt `json:"led_override_color_brightness"` - Adopted FlexBool `json:"adopted"` - HashID string `json:"hash_id"` - DeviceID string `json:"device_id"` - Uplink *Uplink `json:"uplink"` - State FlexInt `json:"state"` - StartDisconnectedMillis FlexInt `json:"start_disconnected_millis"` - UpgradeState FlexInt `json:"upgrade_state"` - StartConnectedMillis FlexInt `json:"start_connected_millis"` - LastSeen FlexInt `json:"last_seen"` - NextInterval FlexInt `json:"next_interval"` - DisconnectionReason string `json:"disconnection_reason"` - Upgradable FlexBool `json:"upgradable"` - AdoptableWhenUpgraded FlexBool `json:"adoptable_when_upgraded"` - UpgradeToFirmware string `json:"upgrade_to_firmware"` - KnownCfgversion string `json:"known_cfgversion"` - Uptime FlexInt `json:"uptime"` - Uptime0 FlexInt `json:"_uptime"` - Locating FlexBool `json:"locating"` - ConnectRequestIP string `json:"connect_request_ip"` - ConnectRequestPort string `json:"connect_request_port"` - SysStats *SysStats `json:"sys_stats"` - SystemStats *SystemStats `json:"system-stats"` - SSHSessionTable []any `json:"ssh_session_table"` - LldpTable []*LLDPTable `json:"lldp_table"` - DisplayableVersion string `json:"displayable_version"` - ConnectionNetworkID string `json:"connection_network_id"` - ConnectionNetworkName string `json:"connection_network_name"` - StartupTimestamp FlexInt `json:"startup_timestamp"` - IsAccessPoint FlexBool `json:"is_access_point"` - SafeForAutoupgrade FlexBool `json:"safe_for_autoupgrade"` - UbbPeerState FlexInt `json:"ubb_peer_state"` - LinkQuality FlexInt `json:"link_quality"` - LinkQualityCurrent FlexInt `json:"link_quality_current"` - GeneralTemperature FlexInt `json:"general_temperature"` - LinkCapacity FlexInt `json:"link_capacity"` - Mode string `json:"mode"` - P2PStats *P2PStats `json:"p2p_stats"` - Isolated FlexBool `json:"isolated"` - RadioTableStats []*RadioTableStats `json:"radio_table_stats"` - PortStats []any `json:"port_stats"` - VwireTable []any `json:"vwire_table"` - VwireVapTable []any `json:"vwire_vap_table"` - DownlinkLLDPMacs []*LLDPTable `json:"downlink_lldp_macs"` - VapTable []*VapTable `json:"vap_table"` - DownlinkTable []any `json:"downlink_table"` - BytesD FlexInt `json:"bytes-d"` - TxBytesD FlexInt `json:"tx_bytes-d"` - RxBytesD FlexInt `json:"rx_bytes-d"` - BytesR FlexInt `json:"bytes-r"` - PeerUbb *UBB `json:"peer_ubb"` - Stat *UBBStat `json:"stat"` - TxBytes FlexInt `json:"tx_bytes"` - RxBytes FlexInt `json:"rx_bytes"` - Bytes FlexInt `json:"bytes"` - NumSta FlexInt `json:"num_sta"` - UserNumSta FlexInt `json:"user-num_sta"` - UserWlanNumSta FlexInt `json:"user-wlan-num_sta"` - XHasSSHHostkey FlexBool `json:"x_has_ssh_hostkey"` + LcmTrackerEnabled FlexBool `json:"lcm_tracker_enabled"` + LedOverride string `json:"led_override"` + LedOverrideColor string `json:"led_override_color"` + LedOverrideColorBrightness FlexInt `json:"led_override_color_brightness"` + LicenseState string `json:"license_state"` + LinkCapacity FlexInt `json:"link_capacity"` + LinkQuality FlexInt `json:"link_quality"` + LinkQualityCurrent FlexInt `json:"link_quality_current"` + LldpTable []LLDPTable `json:"lldp_table"` + Locating FlexBool `json:"locating"` + Mac string `json:"mac"` + MeshStaVapEnabled FlexBool `json:"mesh_sta_vap_enabled"` + MgmtNetworkID string `json:"mgmt_network_id"` + Mode string `json:"mode"` + Model string `json:"model"` + ModelInEol FlexBool `json:"model_in_eol"` + ModelInLts FlexBool `json:"model_in_lts"` + ModelIncompatible FlexBool `json:"model_incompatible"` + Name string `json:"name"` + NextInterval FlexInt `json:"next_interval"` + NumSta FlexInt `json:"num_sta"` + P2PStats *P2PStats `json:"p2p_stats"` + PeerUbb *UBB `fake:"-" json:"peer_ubb"` + ProvisionedAt FlexInt `json:"provisioned_at"` + RadioTable []RadioTable `fakesize:"1" json:"radio_table"` + RadioTableStats []RadioTableStats `fakesize:"1" json:"radio_table_stats"` + RebootDuration FlexInt `json:"reboot_duration"` + RequiredVersion string `json:"required_version"` + RxBytes FlexInt `json:"rx_bytes"` + RxBytesD FlexInt `json:"rx_bytes-d"` + SafeForAutoupgrade FlexBool `json:"safe_for_autoupgrade"` + Serial string `json:"serial"` + SetupID string `json:"setup_id"` + SiteID string `fake:"{uuid}" json:"site_id"` + SiteName string `fake:"{company}" json:"site_name"` + SourceName string `fake:"{animal}" json:"source_name"` + StartConnectedMillis FlexInt `json:"start_connected_millis"` + StartDisconnectedMillis FlexInt `json:"start_disconnected_millis"` + StartupTimestamp FlexInt `json:"startup_timestamp"` + Stat *UBBStat `json:"stat"` + State FlexInt `json:"state"` + SysErrorCaps FlexInt `json:"sys_error_caps"` + SysStats *SysStats `json:"sys_stats"` + SyslogKey string `json:"syslog_key"` + SystemStats *SystemStats `json:"system-stats"` + TwoPhaseAdopt FlexBool `json:"two_phase_adopt"` + TxBytes FlexInt `json:"tx_bytes"` + TxBytesD FlexInt `json:"tx_bytes-d"` + Type string `fake:"{lexify:ubb}" json:"type"` + UbbBssid string `json:"ubb_bssid"` + UbbIsAp FlexBool `json:"ubb_is_ap"` + UbbPairID string `json:"ubb_pair_id"` + UbbPairName string `json:"ubb_pair_name"` + UbbPeerState FlexInt `json:"ubb_peer_state"` + UbbPsk string `json:"ubb_psk"` + UbbSsid string `json:"ubb_ssid"` + Unsupported FlexBool `json:"unsupported"` + UnsupportedReason FlexInt `json:"unsupported_reason"` + Upgradable FlexBool `json:"upgradable"` + UpgradeDuration FlexInt `json:"upgrade_duration"` + UpgradeState FlexInt `json:"upgrade_state"` + UpgradeToFirmware string `json:"upgrade_to_firmware"` + Uplink *Uplink `json:"uplink"` + Uptime FlexInt `json:"uptime"` + Uptime0 FlexInt `json:"_uptime"` + UserNumSta FlexInt `json:"user-num_sta"` + UserWlanNumSta FlexInt `json:"user-wlan-num_sta"` + VapTable []VapTable `fakesize:"1" json:"vap_table"` + Version string `json:"version"` + WifiCaps FlexInt `json:"wifi_caps"` + WlangroupIDNa string `json:"wlangroup_id_na"` + XAesGcm FlexBool `json:"x_aes_gcm"` + XAuthkey string `json:"x_authkey"` + XHasSSHHostkey FlexBool `json:"x_has_ssh_hostkey"` + site *Site `fake:"-"` + + // unknown types, but appear in user capture + PortStats []any `fake:"-" json:"port_stats"` + SSHSessionTable []any `fake:"-" json:"ssh_session_table"` + VwireTable []any `fake:"-" json:"vwire_table"` + VwireVapTable []any `fake:"-" json:"vwire_vap_table"` } type P2PStats struct { diff --git a/ubb_test.go b/ubb_test.go new file mode 100644 index 0000000..f5175fc --- /dev/null +++ b/ubb_test.go @@ -0,0 +1,15 @@ +package unifi_test + +import ( + "github.com/brianvoe/gofakeit/v6" + "github.com/stretchr/testify/require" + "github.com/unpoller/unifi/v5" + "testing" +) + +func TestUBB(test *testing.T) { + ubb := unifi.UBB{} + err := gofakeit.Struct(&ubb) + require.NoError(test, err) + require.NotEmpty(test, ubb.Name) +} diff --git a/uci.go b/uci.go index 2a9a864..549752f 100644 --- a/uci.go +++ b/uci.go @@ -34,86 +34,86 @@ type CIStateTable struct { } type UCI struct { - SiteName string `json:"-"` - SourceName string `json:"-"` - site *Site - RequiredVersion string `json:"required_version"` - PortTable []*Port `json:"port_table"` - LicenseState string `json:"license_state"` - TwoPhaseAdopt FlexBool `json:"two_phase_adopt"` - ConnectedAt FlexInt `json:"connected_at"` - Type string `json:"type"` - InformIP string `json:"inform_ip"` - CfgVersion string `json:"cfgversion"` - BoardRev FlexInt `json:"board_rev"` - Mac string `json:"mac"` - SetupID string `json:"setup_id"` - ProvisionedAt FlexInt `json:"provisioned_at"` - HwCaps FlexInt `json:"hw_caps"` - InformURL string `json:"inform_url"` - RebootDuration FlexInt `json:"reboot_duration"` - UpgradeDuration FlexInt `json:"upgrade_duration"` - EthernetTable []*EthernetTable `json:"ethernet_table"` - ConfigNetwork *ConfigNetwork `json:"config_network"` - Unsupported FlexBool `json:"unsupported"` - BleCaps FlexInt `json:"ble_caps"` - SysErrorCaps FlexInt `json:"sys_error_caps"` - SyslogKey string `json:"syslog_key"` - Model string `json:"model"` - DisconnectedAt FlexInt `json:"disconnected_at"` - Architecture string `json:"architecture"` - ManufacturerID FlexInt `json:"manufacturer_id"` - ModelIncompatible FlexBool `json:"model_incompatible"` - IP string `json:"ip"` - ModelInEol FlexBool `json:"model_in_eol"` - Version string `json:"version"` - AdoptionCompleted FlexBool `json:"adoption_completed"` - UnsupportedReason FlexInt `json:"unsupported_reason"` - CiStateTable *CIStateTable `json:"ci_state_table"` - AnonID string `json:"anon_id"` - AdoptedByClient string `json:"adopted_by_client"` - ModelInLts FlexBool `json:"model_in_lts"` - KernelVersion string `json:"kernel_version"` - Serial string `json:"serial"` - SiteID string `json:"site_id"` - AdoptedAt FlexInt `json:"adopted_at"` - FwCaps FlexInt `json:"fw_caps"` - ID string `json:"_id"` - Adopted FlexBool `json:"adopted"` - Internet FlexBool `json:"internet"` - HashID string `json:"hash_id"` - DeviceID string `json:"device_id"` - State FlexInt `json:"state"` - StartDisconnectedMillis FlexInt `json:"start_disconnected_millis"` - UciConnectTo string `json:"uci_connect_to"` - WanPort string `json:"wan_port"` - WanNetworkGroup string `json:"wan_networkgroup"` - IspName string `json:"isp_name"` - LastSeen FlexInt `json:"last_seen"` - MinInformIntervalSeconds FlexInt `json:"min_inform_interval_seconds"` - Upgradable FlexBool `json:"upgradable"` - AdoptableWhenUpgraded FlexBool `json:"adoptable_when_upgraded"` - RollUpgrade FlexBool `json:"rollupgrade"` - KnownCfgVersion string `json:"known_cfgversion"` - Uptime FlexInt `json:"uptime"` - Uptime0 FlexInt `json:"_uptime"` - Locating FlexBool `json:"locating"` - StartConnectedMillis FlexInt `json:"start_connected_millis"` - NextInterval FlexInt `json:"next_interval"` - SysStats *SysStats `json:"sys_stats"` - SystemStats *SystemStats `json:"system_stats"` - LLDPTable []*LLDPTable `json:"lldp_table"` - DisplayableVersion string `json:"displayable_version"` - StartupTimestamp FlexInt `json:"startup_timestamp"` - IsAccessPoint FlexBool `json:"is_access_point"` - SafeForAutoUpgrade FlexBool `json:"safe_for_autoupgrade"` - DownlinkTable []*DownlinkTable `json:"downlink_table"` - PrevNonBusyState FlexInt `json:"prev_non_busy_state"` - Name string `json:"name"` - LcmBrightness FlexInt `json:"lcm_brightness"` - Stat *UCIStat `json:"stat"` - TxBytes FlexInt `json:"tx_bytes"` - RxBytes FlexInt `json:"rx_bytes"` - Bytes FlexInt `json:"bytes"` - NumSta FlexInt `json:"num_sta"` + AdoptableWhenUpgraded FlexBool `json:"adoptable_when_upgraded"` + Adopted FlexBool `json:"adopted"` + AdoptedAt FlexInt `json:"adopted_at"` + AdoptedByClient string `json:"adopted_by_client"` + AdoptionCompleted FlexBool `json:"adoption_completed"` + AnonID string `json:"anon_id"` + Architecture string `json:"architecture"` + BleCaps FlexInt `json:"ble_caps"` + BoardRev FlexInt `json:"board_rev"` + Bytes FlexInt `json:"bytes"` + CfgVersion string `json:"cfgversion"` + CiStateTable *CIStateTable `json:"ci_state_table"` + ConfigNetwork *ConfigNetwork `json:"config_network"` + ConnectedAt FlexInt `json:"connected_at"` + DeviceID string `json:"device_id"` + DisconnectedAt FlexInt `json:"disconnected_at"` + DisplayableVersion string `json:"displayable_version"` + DownlinkTable []DownlinkTable `fakesize:"1" json:"downlink_table"` + EthernetTable []EthernetTable `fakesize:"1" json:"ethernet_table"` + FwCaps FlexInt `json:"fw_caps"` + HashID string `json:"hash_id"` + HwCaps FlexInt `json:"hw_caps"` + ID string `json:"_id"` + IP string `json:"ip"` + InformIP string `json:"inform_ip"` + InformURL string `json:"inform_url"` + Internet FlexBool `json:"internet"` + IsAccessPoint FlexBool `json:"is_access_point"` + IspName string `json:"isp_name"` + KernelVersion string `json:"kernel_version"` + KnownCfgVersion string `json:"known_cfgversion"` + LLDPTable []LLDPTable `fakesize:"1" json:"lldp_table"` + LastSeen FlexInt `json:"last_seen"` + LcmBrightness FlexInt `json:"lcm_brightness"` + LicenseState string `json:"license_state"` + Locating FlexBool `json:"locating"` + Mac string `json:"mac"` + ManufacturerID FlexInt `json:"manufacturer_id"` + MinInformIntervalSeconds FlexInt `json:"min_inform_interval_seconds"` + Model string `json:"model"` + ModelInEol FlexBool `json:"model_in_eol"` + ModelInLts FlexBool `json:"model_in_lts"` + ModelIncompatible FlexBool `json:"model_incompatible"` + Name string `json:"name"` + NextInterval FlexInt `json:"next_interval"` + NumSta FlexInt `json:"num_sta"` + PortTable []Port `fakesize:"1" json:"port_table"` + PrevNonBusyState FlexInt `json:"prev_non_busy_state"` + ProvisionedAt FlexInt `json:"provisioned_at"` + RebootDuration FlexInt `json:"reboot_duration"` + RequiredVersion string `json:"required_version"` + RollUpgrade FlexBool `json:"rollupgrade"` + RxBytes FlexInt `json:"rx_bytes"` + SafeForAutoUpgrade FlexBool `json:"safe_for_autoupgrade"` + Serial string `json:"serial"` + SetupID string `json:"setup_id"` + SiteID string `fake:"{uuid}" json:"site_id"` + SiteName string `fake:"{company}" json:"site_name"` + SourceName string `fake:"{animal}" json:"source_name"` + StartConnectedMillis FlexInt `json:"start_connected_millis"` + StartDisconnectedMillis FlexInt `json:"start_disconnected_millis"` + StartupTimestamp FlexInt `json:"startup_timestamp"` + Stat *UCIStat `json:"stat"` + State FlexInt `json:"state"` + SysErrorCaps FlexInt `json:"sys_error_caps"` + SysStats *SysStats `json:"sys_stats"` + SyslogKey string `json:"syslog_key"` + SystemStats *SystemStats `json:"system_stats"` + TwoPhaseAdopt FlexBool `json:"two_phase_adopt"` + TxBytes FlexInt `json:"tx_bytes"` + Type string `fake:"{lexify:uci}" json:"type"` + UciConnectTo string `json:"uci_connect_to"` + Unsupported FlexBool `json:"unsupported"` + UnsupportedReason FlexInt `json:"unsupported_reason"` + Upgradable FlexBool `json:"upgradable"` + UpgradeDuration FlexInt `json:"upgrade_duration"` + Uptime FlexInt `json:"uptime"` + Uptime0 FlexInt `json:"_uptime"` + Version string `json:"version"` + WanNetworkGroup string `json:"wan_networkgroup"` + WanPort string `json:"wan_port"` + site *Site `fake:"-"` } diff --git a/uci_test.go b/uci_test.go new file mode 100644 index 0000000..4b33e1a --- /dev/null +++ b/uci_test.go @@ -0,0 +1,15 @@ +package unifi_test + +import ( + "github.com/brianvoe/gofakeit/v6" + "github.com/stretchr/testify/require" + "github.com/unpoller/unifi/v5" + "testing" +) + +func TestUCI(test *testing.T) { + uci := unifi.UCI{} + err := gofakeit.Struct(&uci) + require.NoError(test, err) + require.NotEmpty(test, uci.Name) +}