Api permission

Added permission testing framework for api, for now for domain.