The New York City mayor is facing a major political test ahead of the state's upcoming congressional primaries.