Is it fair for me to drink caffeine during tests?
That would be totally acceptable. Remember, you are also in a totally different state if you went to the toilet right before the exam. If you drank a litre of water in the morning. If you ate something for breakfast that happens to contain lots of short-chained carbohydrates, providing lots of energy for your brain.

You have to draw the line somewere and coffee is definitely acceptable, if not expected.

Edit:
As several comments suggest, your other question about rudeness because of smelling beverages: that's different from course to course, and you will probably have to employ some degree of common sense there. People are usually not bothered by coffee smell as opposed to french fries or the sounds of eating potato crisps. If in doubt, just ask your TA or fellow students before going to the exam.