Skip to content

Commit

Permalink
adding one more search criterion for getting MX-record
Browse files Browse the repository at this point in the history
  • Loading branch information
skudriavtsev committed Mar 21, 2023
1 parent 6775107 commit b0c55f5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion object_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type IBObjectManager interface {
SearchHostRecordByAltId(internalId string, ref string, eaNameForInternalId string) (*HostRecord, error)
GetHostRecordByRef(ref string) (*HostRecord, error)
GetIpAddressFromHostRecord(host HostRecord) (string, error)
GetMXRecord(dnsView string, fqdn string, mx string) (*RecordMX, error)
GetMXRecord(dnsView string, fqdn string, mx string, preference uint32) (*RecordMX, error)
GetMXRecordByRef(ref string) (*RecordMX, error)
GetNetwork(netview string, cidr string, isIPv6 bool, ea EA) (*Network, error)
GetNetworkByRef(ref string) (*Network, error)
Expand Down
3 changes: 2 additions & 1 deletion object_manager_mx_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (objMgr *ObjectManager) GetMXRecordByRef(ref string) (*RecordMX, error) {
return recordMX, err
}

func (objMgr *ObjectManager) GetMXRecord(dnsView string, fqdn string, mx string) (*RecordMX, error) {
func (objMgr *ObjectManager) GetMXRecord(dnsView string, fqdn string, mx string, preference uint32) (*RecordMX, error) {
if dnsView == "" || fqdn == "" {
return nil, fmt.Errorf("'DNS view' and 'fqdn' are required to retrieve a unique mx record")
}
Expand All @@ -61,6 +61,7 @@ func (objMgr *ObjectManager) GetMXRecord(dnsView string, fqdn string, mx string)
"view": dnsView,
"name": fqdn,
"mail_exchanger": mx,
"preference": fmt.Sprintf("%d", preference),
}
queryParams := NewQueryParams(false, sf)
err := objMgr.connector.GetObject(recordMX, "", queryParams, &res)
Expand Down
3 changes: 2 additions & 1 deletion object_manager_mx_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ var _ = Describe("Object Manager: MX-record", func() {
"view": dnsView,
"name": fqdn,
"mail_exchanger": mx,
"preference": fmt.Sprintf("%d", preference),
}
nwFakeConnector := &fakeConnector{
getObjectObj: NewEmptyRecordMX(),
Expand All @@ -202,7 +203,7 @@ var _ = Describe("Object Manager: MX-record", func() {
var actualRecord *RecordMX
var err error
It("should pass expected MX record object to GetObject", func() {
actualRecord, err = objMgr.GetMXRecord(dnsView, fqdn, mx)
actualRecord, err = objMgr.GetMXRecord(dnsView, fqdn, mx, preference)
})
It("should return expected MX record Object", func() {
Expect(actualRecord).NotTo(BeNil())
Expand Down

0 comments on commit b0c55f5

Please sign in to comment.