Your employer has no automatic legal right to test you for drug or alcohol abuse, but you may have expressly given your permission to testing when you signed your written contract of employment.
Whether your employer can discipline or dismiss you for refusing a test will depend, among other factors, on the nature of your work.
Where your employer keeps records of such tests, it must comply with the data handling rules issued by the Information Commissioner. For example, it must only hold the data for a limited time and in a secure environment.
Also see the TUC's guidance on Drug testing in the workplace.