a fe wmore tweaks to align outputs.a
This commit is contained in:
parent
068ee31dfa
commit
8d9af25d47
|
|
@ -30,9 +30,11 @@ func TestUniReq(t *testing.T) {
|
|||
a := assert.New(t)
|
||||
p := "/test/path"
|
||||
u := "http://some.url:8443"
|
||||
|
||||
// Test empty parameters.
|
||||
authReq := &Unifi{Client: &http.Client{}, Config: &Config{URL: u, DebugLog: discardLogs}}
|
||||
r, err := authReq.UniReq(p, "")
|
||||
|
||||
a.Nil(err, "newrequest must not produce an error")
|
||||
a.EqualValues(p, r.URL.Path,
|
||||
"the provided apiPath was not added to http request")
|
||||
|
|
@ -45,11 +47,13 @@ func TestUniReq(t *testing.T) {
|
|||
authReq = &Unifi{Client: &http.Client{}, Config: &Config{URL: "http://some.url:8443", DebugLog: discardLogs}}
|
||||
r, err = authReq.UniReq(p, k)
|
||||
a.Nil(err, "newrequest must not produce an error")
|
||||
|
||||
a.EqualValues(p, r.URL.Path,
|
||||
"the provided apiPath was not added to http request")
|
||||
a.EqualValues(u, r.URL.Scheme+"://"+r.URL.Host, "URL improperly encoded")
|
||||
a.EqualValues("POST", r.Method, "with parameters the method must be POST")
|
||||
a.EqualValues("application/json", r.Header.Get("Accept"), "Accept header must be set to application/json")
|
||||
|
||||
// Check the parameters.
|
||||
d, err := ioutil.ReadAll(r.Body)
|
||||
a.Nil(err, "problem reading request body, POST parameters may be malformed")
|
||||
|
|
@ -61,28 +65,31 @@ func TestUniReqPut(t *testing.T) {
|
|||
a := assert.New(t)
|
||||
p := "/test/path"
|
||||
u := "http://some.url:8443"
|
||||
|
||||
// Test empty parameters.
|
||||
authReq := &Unifi{Client: &http.Client{}, Config: &Config{URL: u, DebugLog: discardLogs}}
|
||||
r, err := authReq.UniReqPut(p, "")
|
||||
_, err := authReq.UniReqPut(p, "")
|
||||
a.NotNil(err, "empty params must produce an error")
|
||||
|
||||
// Test with parameters
|
||||
k := "key1=value9&key2=value7"
|
||||
authReq = &Unifi{Client: &http.Client{}, Config: &Config{URL: "http://some.url:8443", DebugLog: discardLogs}}
|
||||
r, err = authReq.UniReqPut(p, k)
|
||||
r, err := authReq.UniReqPut(p, k)
|
||||
a.Nil(err, "newrequest must not produce an error")
|
||||
|
||||
a.EqualValues(p, r.URL.Path,
|
||||
"the provided apiPath was not added to http request")
|
||||
a.EqualValues(u, r.URL.Scheme+"://"+r.URL.Host, "URL improperly encoded")
|
||||
a.EqualValues("PUT", r.Method, "with parameters the method must be POST")
|
||||
a.EqualValues("application/json", r.Header.Get("Accept"), "Accept header must be set to application/json")
|
||||
|
||||
// Check the parameters.
|
||||
d, err := ioutil.ReadAll(r.Body)
|
||||
a.Nil(err, "problem reading request body, PUT parameters may be malformed")
|
||||
a.EqualValues(k, string(d), "PUT parameters improperly encoded")
|
||||
}
|
||||
|
||||
/* NOT DONE: OPEN web server, check parameters posted, more. This test is incomplete.
|
||||
/* NOT DONE: OPEN web server, check parameters posted, more. These tests are incomplete.
|
||||
a.EqualValues(`{"username": "user1","password": "pass2"}`, string(post_params),
|
||||
"user/pass json parameters improperly encoded")
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -53,28 +53,7 @@ type USG struct {
|
|||
SpeedtestStatusSaved FlexBool `json:"speedtest-status-saved"`
|
||||
Wan1 Wan `json:"wan1"`
|
||||
Wan2 Wan `json:"wan2"`
|
||||
PortTable []struct {
|
||||
Name string `json:"name"`
|
||||
Ifname string `json:"ifname"`
|
||||
IP string `json:"ip"`
|
||||
Netmask string `json:"netmask"`
|
||||
Mac string `json:"mac"`
|
||||
Up FlexBool `json:"up"`
|
||||
Speed FlexInt `json:"speed"`
|
||||
FullDuplex FlexBool `json:"full_duplex"`
|
||||
RxBytes FlexInt `json:"rx_bytes"`
|
||||
RxDropped FlexInt `json:"rx_dropped"`
|
||||
RxErrors FlexInt `json:"rx_errors"`
|
||||
RxPackets FlexInt `json:"rx_packets"`
|
||||
TxBytes FlexInt `json:"tx_bytes"`
|
||||
TxDropped FlexInt `json:"tx_dropped"`
|
||||
TxErrors FlexInt `json:"tx_errors"`
|
||||
TxPackets FlexInt `json:"tx_packets"`
|
||||
RxMulticast FlexInt `json:"rx_multicast"`
|
||||
Enable FlexBool `json:"enable"`
|
||||
DNS []string `json:"dns,omitempty"`
|
||||
Gateway string `json:"gateway,omitempty"`
|
||||
} `json:"port_table"`
|
||||
PortTable []*Port `json:"port_table"`
|
||||
NetworkTable NetworkTable `json:"network_table"`
|
||||
Uplink Uplink `json:"uplink"`
|
||||
Stat USGStat `json:"stat"`
|
||||
|
|
@ -180,6 +159,7 @@ type SpeedtestStatus struct {
|
|||
Runtime FlexInt `json:"runtime"`
|
||||
ServerDesc string `json:"server_desc,omitempty"`
|
||||
Server *SpeedtestServer `json:"server"`
|
||||
SourceInterface string `json:"source_interface"`
|
||||
StatusDownload FlexInt `json:"status_download"`
|
||||
StatusPing FlexInt `json:"status_ping"`
|
||||
StatusSummary FlexInt `json:"status_summary"`
|
||||
|
|
|
|||
|
|
@ -13,16 +13,9 @@ type USW struct {
|
|||
Adopted FlexBool `json:"adopted"`
|
||||
BoardRev FlexInt `json:"board_rev"`
|
||||
Cfgversion string `json:"cfgversion"`
|
||||
ConfigNetwork struct {
|
||||
Type string `json:"type"`
|
||||
IP string `json:"ip"`
|
||||
} `json:"config_network"`
|
||||
ConfigNetwork *ConfigNetwork `json:"config_network"`
|
||||
Dot1XPortctrlEnabled FlexBool `json:"dot1x_portctrl_enabled"`
|
||||
EthernetTable []struct {
|
||||
Mac string `json:"mac"`
|
||||
NumPort FlexInt `json:"num_port,omitempty"`
|
||||
Name string `json:"name"`
|
||||
} `json:"ethernet_table"`
|
||||
EthernetTable []*EthernetTable `json:"ethernet_table"`
|
||||
FlowctrlEnabled FlexBool `json:"flowctrl_enabled"`
|
||||
FwCaps FlexInt `json:"fw_caps"`
|
||||
HasFan FlexBool `json:"has_fan"`
|
||||
|
|
@ -73,12 +66,7 @@ type USW struct {
|
|||
GeneralTemperature FlexInt `json:"general_temperature"`
|
||||
Overheating FlexBool `json:"overheating"`
|
||||
TotalMaxPower FlexInt `json:"total_max_power"`
|
||||
DownlinkTable []struct {
|
||||
PortIdx FlexInt `json:"port_idx"`
|
||||
Speed FlexInt `json:"speed"`
|
||||
FullDuplex FlexBool `json:"full_duplex"`
|
||||
Mac string `json:"mac"`
|
||||
} `json:"downlink_table"`
|
||||
DownlinkTable []*DownlinkTable `json:"downlink_table"`
|
||||
Uplink Uplink `json:"uplink"`
|
||||
LastUplink struct {
|
||||
UplinkMac string `json:"uplink_mac"`
|
||||
|
|
@ -109,7 +97,8 @@ type MacTable struct {
|
|||
Mac string `json:"mac"`
|
||||
}
|
||||
|
||||
// Port is a physical connection on a USW or UDM.
|
||||
// Port is a physical connection on a USW or Gateway.
|
||||
// Not every port has the same capabilities.
|
||||
type Port struct {
|
||||
AggregatedBy FlexBool `json:"aggregated_by"`
|
||||
Autoneg FlexBool `json:"autoneg,omitempty"`
|
||||
|
|
|
|||
|
|
@ -9,15 +9,15 @@ type UXG struct {
|
|||
IP string `json:"ip"`
|
||||
Mac string `json:"mac"`
|
||||
Model string `json:"model"`
|
||||
ModelInLts bool `json:"model_in_lts"`
|
||||
ModelInEol bool `json:"model_in_eol"`
|
||||
ModelInLts FlexBool `json:"model_in_lts"`
|
||||
ModelInEol FlexBool `json:"model_in_eol"`
|
||||
Type string `json:"type"`
|
||||
Version string `json:"version"`
|
||||
Adopted bool `json:"adopted"`
|
||||
Adopted FlexBool `json:"adopted"`
|
||||
SiteID string `json:"site_id"`
|
||||
Cfgversion string `json:"cfgversion"`
|
||||
SyslogKey string `json:"syslog_key"`
|
||||
ConfigNetwork ConfigNetwork `json:"config_network"`
|
||||
ConfigNetwork *ConfigNetwork `json:"config_network"`
|
||||
SetupID string `json:"setup_id"`
|
||||
LicenseState string `json:"license_state"`
|
||||
ConfigNetworkLan *ConfigNetworkLan `json:"config_network_lan"`
|
||||
|
|
@ -28,22 +28,22 @@ type UXG struct {
|
|||
Architecture string `json:"architecture"`
|
||||
BoardRev FlexInt `json:"board_rev"`
|
||||
ManufacturerID FlexInt `json:"manufacturer_id"`
|
||||
Internet bool `json:"internet"`
|
||||
ModelIncompatible bool `json:"model_incompatible"`
|
||||
Internet FlexBool `json:"internet"`
|
||||
ModelIncompatible FlexBool `json:"model_incompatible"`
|
||||
EthernetTable []*EthernetTable `json:"ethernet_table"`
|
||||
PortTable []*Port `json:"port_table"`
|
||||
EthernetOverrides []*EthernetOverrides `json:"ethernet_overrides"`
|
||||
UsgCaps FlexInt `json:"usg_caps"`
|
||||
HasSpeaker bool `json:"has_speaker"`
|
||||
HasEth1 bool `json:"has_eth1"`
|
||||
HasSpeaker FlexBool `json:"has_speaker"`
|
||||
HasEth1 FlexBool `json:"has_eth1"`
|
||||
FwCaps FlexInt `json:"fw_caps"`
|
||||
HwCaps FlexInt `json:"hw_caps"`
|
||||
WifiCaps FlexInt `json:"wifi_caps"`
|
||||
SwitchCaps *SwitchCaps `json:"switch_caps"`
|
||||
HasFan bool `json:"has_fan"`
|
||||
HasTemperature bool `json:"has_temperature"`
|
||||
HasFan FlexBool `json:"has_fan"`
|
||||
HasTemperature FlexBool `json:"has_temperature"`
|
||||
Temperatures []*Temperature `json:"temperatures"`
|
||||
Storage []Storage `json:"storage"`
|
||||
Storage []*Storage `json:"storage"`
|
||||
RulesetInterfaces interface{} `json:"ruleset_interfaces"`
|
||||
ConnectedAt FlexInt `json:"connected_at"`
|
||||
ProvisionedAt FlexInt `json:"provisioned_at"`
|
||||
|
|
@ -51,36 +51,36 @@ type UXG struct {
|
|||
LedOverrideColor string `json:"led_override_color"`
|
||||
LedOverrideColorBrightness FlexInt `json:"led_override_color_brightness"`
|
||||
OutdoorModeOverride string `json:"outdoor_mode_override"`
|
||||
LcmBrightnessOverride bool `json:"lcm_brightness_override"`
|
||||
LcmIdleTimeoutOverride bool `json:"lcm_idle_timeout_override"`
|
||||
LcmBrightnessOverride FlexBool `json:"lcm_brightness_override"`
|
||||
LcmIdleTimeoutOverride FlexBool `json:"lcm_idle_timeout_override"`
|
||||
Name string `json:"name"`
|
||||
Unsupported bool `json:"unsupported"`
|
||||
Unsupported FlexBool `json:"unsupported"`
|
||||
UnsupportedReason FlexInt `json:"unsupported_reason"`
|
||||
Serial string `json:"serial"`
|
||||
HashID string `json:"hash_id"`
|
||||
TwoPhaseAdopt bool `json:"two_phase_adopt"`
|
||||
TwoPhaseAdopt FlexBool `json:"two_phase_adopt"`
|
||||
DeviceID string `json:"device_id"`
|
||||
State FlexInt `json:"state"`
|
||||
StartDisconnectedMillis int64 `json:"start_disconnected_millis"`
|
||||
StartDisconnectedMillis FlexInt `json:"start_disconnected_millis"`
|
||||
UpgradeState FlexInt `json:"upgrade_state"`
|
||||
StartConnectedMillis int64 `json:"start_connected_millis"`
|
||||
StartConnectedMillis FlexInt `json:"start_connected_millis"`
|
||||
LastSeen FlexInt `json:"last_seen"`
|
||||
Uptime FlexInt `json:"uptime"`
|
||||
UnderscoreUptime FlexInt `json:"_uptime"`
|
||||
Locating bool `json:"locating"`
|
||||
Locating FlexBool `json:"locating"`
|
||||
SysStats *SysStats `json:"sys_stats"`
|
||||
SystemStats *SystemStats `json:"system-stats"`
|
||||
GuestKicks FlexInt `json:"guest_kicks"`
|
||||
GuestToken string `json:"guest_token"`
|
||||
UptimeStats map[string]*UptimeStats `json:"uptime_stats"`
|
||||
Overheating bool `json:"overheating"`
|
||||
Overheating FlexBool `json:"overheating"`
|
||||
GeoInfo map[string]*GeoInfo `json:"geo_info"`
|
||||
LedState *LedState `json:"led_state"`
|
||||
SpeedtestStatus *SpeedtestStatus `json:"speedtest-status"`
|
||||
SpeedtestStatusSaved bool `json:"speedtest-status-saved"`
|
||||
SpeedtestStatusSaved FlexBool `json:"speedtest-status-saved"`
|
||||
Wan1 *Wan `json:"wan1"`
|
||||
Wan2 *Wan `json:"wan2"`
|
||||
Uplink Uplink `json:"uplink"`
|
||||
Uplink *Uplink `json:"uplink"`
|
||||
DownlinkTable []*DownlinkTable `json:"downlink_table"`
|
||||
NetworkTable []*NetworkTable `json:"network_table"`
|
||||
KnownCfgversion string `json:"known_cfgversion"`
|
||||
|
|
@ -91,8 +91,8 @@ type UXG struct {
|
|||
ConsideredLostAt FlexInt `json:"considered_lost_at"`
|
||||
Stat *UXGStat `json:"stat"`
|
||||
TxBytes FlexInt `json:"tx_bytes"`
|
||||
RxBytes int64 `json:"rx_bytes"`
|
||||
Bytes int64 `json:"bytes"`
|
||||
RxBytes FlexInt `json:"rx_bytes"`
|
||||
Bytes FlexInt `json:"bytes"`
|
||||
NumSta FlexInt `json:"num_sta"`
|
||||
WlanNumSta FlexInt `json:"wlan-num_sta"`
|
||||
LanNumSta FlexInt `json:"lan-num_sta"`
|
||||
|
|
@ -121,11 +121,13 @@ type DownlinkTable struct {
|
|||
Mac string `json:"mac"`
|
||||
}
|
||||
|
||||
// LedState is incuded with newer devices.
|
||||
type LedState struct {
|
||||
Pattern string `json:"pattern"`
|
||||
Tempo FlexInt `json:"tempo"`
|
||||
}
|
||||
|
||||
// GeoInfo is incuded with certain devices.
|
||||
type GeoInfo struct {
|
||||
Accuracy FlexInt `json:"accuracy"`
|
||||
Address string `json:"address"`
|
||||
|
|
@ -141,14 +143,14 @@ type GeoInfo struct {
|
|||
Timezone string `json:"timezone"`
|
||||
}
|
||||
|
||||
// UptimeStats is incuded with certain devices.
|
||||
type UptimeStats struct {
|
||||
Availability FlexInt `json:"availability"`
|
||||
LatencyAverage FlexInt `json:"latency_average"`
|
||||
TimePeriod FlexInt `json:"time_period"`
|
||||
}
|
||||
|
||||
// UDMStat holds the "stat" data for a dream machine.
|
||||
// A dream machine is a USG + USW + Controller.
|
||||
// UXGStat holds the "stat" data for a 10Gb gateway.
|
||||
type UXGStat struct {
|
||||
*Gw `json:"gw"`
|
||||
*Sw `json:"sw"`
|
||||
|
|
|
|||
Loading…
Reference in New Issue