Tom Cotton, long the president's most reliable ally in the Senate, has spent the past week fighting the White House.