New Zealand and the Cook Islands have signed a defense and security pact, easing over a year of tension between them.