Whenever we examine a matter of freedom, power and negative consequences, we must first examine the degree of consensuality: the ability to provide or withhold meaningful mutual consent. Generally, the greater the degree of consensuality, the greater the freedom allowed both parties. When consensuality is absent, we must impose regulation to prevent abuse, exploitation and oppression.
Note that for the purposes of this discussion we are assuming adult mental and psychological ability and fitness to enter into an agreement. The ethics of custodial relationships have a vastly different character and are a matter for a different debate.
The most important component of consensuality is equality of power. When both parties to an agreement have equal power to accept, reject or define the terms of that agreement, we can presume on that basis alone that the agreement does not violate moral stricture. When a significant difference in power exists between the two parties, we are morally obligated to take steps to ensure that the party with the greater power does not use that power to oppress or exploit.
For instance, the government, by virtue of its coercive abilities, holds a greater degree of power than the individual. The individual does not have a meaningful choice to accept or reject the law; submission is imposed on him or her merely by the fact and place of his or her birth. Such a condition does not preclude consensuality, but it requires the application of regulation to the party (the government) holding the excess primary power. And that is precisely the function of the Constitution, especially the Bill of Rights; and the obvious power imbalance is precisely the moral justification for the Constitution.
I know that Libertarians will disagree on principle with the above statement. They see the critical moral component as the imposition of physical force and reject on principle the relevance of of non-force-related power imbalances on consensuality. Since they hold this tenet as a funamental axiom, I cannot reply rationally to such an assertion. Obviously, if you hold such a tenet my entire argument fails to comply; I will assume your objection.
There are other aspect of this issue which I do not consider here (e.g. degree of intrusiveness and customary requirements) because they are not particularly relevant to the specific issue of drug testing.
In many cases, an employer holds a greater degree of practical econimic power than an individual employee, especially an unskilled or low-skilled employee. Therefore, we are morally justified presuming we as a society may examine agreements to ensure that the power imbalance does not lead to oppression or exploitation and ensure full consensuality.
Our test is simple: We can prohibit any provision that a reasonable person would not categorically agree to if he or she had economic power equal to his or employer.
Clearly fitness for duty fails this test. If a person wishes to perform a particular duty, he must obviously consent to show his or her ability to perform it. Therefore, if a particular provision is necessary for a particlar job, we cannot prohibit it.
Lacking necessity, the existence of the Fourth Amendenment shows on its face that a reasonable person would not categorically consent to an unreasonable search. Therefore, lacking necessity, drug testing passes our test: It is a morally incorrect provision to insist on and we may prohibit it.
Drug use per se does not imply unfitness for duty, except in very specialized occupations as noted earlier in this thread. It is certainly true that excessive drug usage might render one unfit for duty, but then again so might many other legal or normal activities. Therefore proving lack of drug use in general does not meet our test of necessity.
Nor is illegality per se a sufficient justification for a provision. Again, we look to the Constitution for guidance as to the provisions to which a reasonable person is not expected to categorically consent. Again the Constitution is very clear: the implication of the Fourth and Fifth Amendments is that a citizen may depend on the presumption of the legality of his or her behavior and need not accept intrusive measures to establish such legality without specific reason and warrant.
To impose by any power a condition to which a reasonable person would not categorically consent by definition constitutes oppression, and is thus immoral, by the same principles as we accept our Constitution.
I am wary of the Libertarian arguments that using power other than physical force to come to an advantageous agreement is always consensual. I do not wish to grant to the owners of capital and their managers powers explicity denied a democratic government.