Your Basic Rights at the border (including airport)
It is illegal for officers to stop, search, detain you based on your religion, gender, ethnicity, political belief, or race.
CBP can ask questions about your immigration status.CBP officers have authority to ask your immigration status, including detailed information about your arrival. They can ask why (the purpose) you come to the U.S., how long you plan to stay, Who you will stay with, where you will go, including activities that you plan to do. After they ask, and gather all information, they also have authority to make a discretionary decision if you should be allowed in the U.S. or not. Refusing to answer questions may put you in a bad spot and CBP officers can deny you entry.
CBP can search your electronic devices.Although you tell CBP officer that you do not give them a consent to search, it probably will not stop CBP from doing so. CBP can search your electronic devices and download full contents from your devices and save your data. In the 2009 CBP policy, they are not required to give your device back and can perform more search at a different location. ("forensic" search). If your devices have password protection, and you deny access to it, you may be denied entry, if you are not a U.S.citizen or a legal permanent resident.