The U.S. Anti-Doping Agency (USADA) administers the UFC's drug testing policy. They have a website at ufc.usada.org, and on this website you can read the 21-page policy (pdf), which took effect on July 1, 2015.
Every UFC fighter is subject to unannounced, year-round drug testing by the USADA. The sanctions for testing positive is dependent on the substance found. For performance-enhancing drugs such as steroids, growth hormones, blood doping, etc., the ban is 2 years for the first offense. For other drugs, such as marijuana or cocaine, the ban is 1 year for the first offense. For subsequent offenses, the length of the ban doubles. Two years can be added to the ban for "aggravating circumstances," which are defined in the policy.
You can see which athletes have been tested and how many times on the Athlete Test History page of the website. So far this year, 240 athletes have been tested 335 times.