open-nomad/ui/tests/utils/set-policy.js
2023-04-10 15:36:59 +00:00

15 lines
405 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
export default function setPolicy(policy) {
const { id: policyId } = server.create('policy', policy);
const clientToken = server.create('token', { type: 'client' });
clientToken.policyIds = [policyId];
clientToken.save();
window.localStorage.clear();
window.localStorage.nomadTokenSecret = clientToken.secretId;
}