cheated, got pregnant...need help.

So a bit a back story, me and my husband have been togetger almost 2 years. We got married really quickly, we started trying for a baby immediately. after a year and 2 miscarriaged we decided to take a break from trying. So I stopped tracking my cycles. Last year after our one year anniversary we started fighting and it got to the point where we were talking about getting divorced, we had even started looking for a lawyer. We have custody of my brother (we got custody of him after my mother abused him) and we were trying to figure out who would move out and how we would pay the bills for the house since neither of us could afford it on our own and we were half way through a one year lease with no option to break the lease. So in october I had gotten a call from an ex tgat was struggling with depression and was suicidal. I went to him to talk him into seeking help. Instead we ended up sleeping together. The next day I called my husband and told him what had happened and we made a joint decision to not get the plan B pill since neither of us thought I would get pregnant. After that me and my husband talked about things and decided to stay together and work on our marriage. Four weeks later I found out I was pregnant. We were both shocked but knew it was a possibility since I had stopped tracking and did not take the plan b pill. and every since my husband has been 100% involved. extremely supportive and the best partner I could ever ask for. HE does everything for me and the baby and it breaks my heart knowing what I did. My ex found out I was pregnant. we had never told him. and now he wants to be involved and wants a dna test done. I am literally due in 3 weeks and I dont know what to do. if I deny him the dna test he has already made it clear he will not take it to court but he really wants to be included. my husbamd said he is okay with it. but I am pretty sure he wont be when my ex starts asking for visits. I dont know what to do.