The world tests new presidents.

President John F. Kennedy was in office less than three months when he was blindsided by a CIA-led invasion of Cuba that ended in humiliating defeat at the Bay of Pigs. He and the CIA never trusted each other after that.

Two months later, at the height of the Cold War, JFK met Soviet Premier Nikita Khrushchev for the first time. Poorly prepared and heavily medicated for back pain, Kennedy came across as weak and out of his depth. Khruschchev was emboldened to send nuclear weapons to Cuba, which brought the two nations to the brink of war.

President Jimmy Carter ran as a Washington outsider, and Washington insiders didn’t take it well. Right off the bat, he clashed with the Democrats who ran Congress, members of his own party, over public works spending. He never established the working relationships with Congress necessary to advance his agenda.

Soon after he was sworn in, President Bill Clinton got in trouble with both Congress and the Pentagon over his pledge to lift the ban on gays in the military. Clinton had to back down, which emboldened Republican Senate leader Bob Dole to adopt as a default setting opposition to anything Clinton proposed.

I expect all presidents wish they had “do-overs” early in their first terms. President George W. Bush probably wishes he hadn’t told his people not to worry so much about the threat from terrorists. President Barack Obama probably wishes he’d reached out more to Republicans in Congress and had fashioned his own health reform bill instead of letting Nancy Pelosi and Harry Reid carry the ball.

President-elect Donald J. Trump has yet to take office, but he is already being tested. He’s off to a terrible start with the CIA and other intelligence agencies. He has doubted their findings, undermined their credibility, even compared them to Nazis. The lack of trust between a president and these critical national security agencies has never been so publicly expressed.

Harsh words invite retaliation. The people in the intelligence community Trump has criticized may not be the ones who leaked the document to Buzzfeed containing unverified, scandalous claims about Trump, though strategic leaks are the most common weapon used in Washington battles. But just by including the document in briefing papers given to both Obama and Trump, top intelligence officials gave the mainstream media permission to talk out loud about charges that had previously only been whispered.

On another front, Russia’s Vladimir Putin is likely sizing up Trump just as Khruschchev sized up JFK, with world events hanging on his calculations. The leaders of other nations — China, Iran, North Korea — may be preparing their own test for the rookie president.

Trump’s relationship with Congress is also fraught. He campaigned against the Washington Republican establishment almost as hard as he campaigned against Democrats. Trump’s dealings with House Speaker Paul Ryan have run hot and cold for the last year, and Trump is still gloating about the primary defeats he dealt opponents like Lindsey Graham, Marco Rubio and Rand Paul.

But those men aren’t just vanquished opponents, they are sitting senators with the power to stop Trump’s initiatives in their tracks. Actions have consequences. Do you think a day goes by without Rubio remembering Trump’s taunts of “Little Marco,” which helped kill his presidential bid? Rubio is among a handful of ambitious Republicans already looking to the next presidential campaign. Their agendas, both substantive and political, are not Trump’s.

All presidents face the test of building an administration capable of speaking with one voice, making sound decisions and executing complicated plans. Trump’s cabinet nominees are already disavowing his campaign positions. White House veterans worry that Trump’s emerging organization, much like its leader, will be characterized by chaos and competition, not discipline and coherence.

Trump is still relishing his November victory, as well he should. He enjoyed nothing more than pumping up his fans at mass rallies, which he plans to keep doing while in office. But the adulation of friendly crowds and the votes of strategically-located rust belt supporters don’t count for much now that the election’s over. Trump’s in Washington now, and his success depends not on voters but on other leaders with their own power bases — Congress members, generals, intelligence chiefs — and on thousands of members of the permanent government who were there before Trump arrived and will be there long after he’s gone.

Trump has had tremendous success in the last year, and nobody should write him off. But Washington can be a tough town, especially for outsiders and newcomers. As President Harry Truman is, perhaps inaccurately, credited with saying, “If you want a friend in Washington, get a dog.”

Donald Trump has never been fond of pets, so he’s unlikely to follow Truman’s advice. But this much is certain: He will be tested.

— Rick Holmes writes for GateHouse Media and the MetroWest Daily News. He can be reached at rholmes@wickedlocal.com. Like Rick on Facebook at Holmes & Co., and follow him @HolmesAndCo.