The immediate crisis involves a pair of post-revolutionary Arab countries — Egypt and Libya — that Obama has worked to ensure will be supporters of the United States as they endure difficult transitions from autocracies to self-government. Now part of a bitter U.S. presidential campaign, the attacks this week will test the diplomacy Obama will use to salvage two badly damaged relationships, as well as his broader remedial project with the Islamic world. But first he must define again who are his nation’s friends and how in the future to describe them.