Skip to content

Commit

Permalink
[Security Solution][Serverless] Add HTTP header 'x-elastic-internal-p…
Browse files Browse the repository at this point in the history
…roduct' to e2e Role/User loader (#163026)

## Summary

- Adds http header `x-elastic-internal-product` to the calls made form
the Role/User loader to create the roles in cypress tests
  • Loading branch information
paul-tavares committed Aug 2, 2023
1 parent 2c6fd26 commit c0030da
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const ignoreHttp409Error = (error: AxiosError) => {
throw error;
};

const DEFAULT_HEADERS = Object.freeze({
'x-elastic-internal-product': 'security-solution',
});

export interface LoadedRoleAndUser {
role: string;
username: string;
Expand Down Expand Up @@ -75,6 +79,9 @@ export class RoleAndUserLoader<R extends Record<string, Role> = Record<string, R
.request({
method: 'PUT',
path: `/api/security/role/${roleName}`,
headers: {
...DEFAULT_HEADERS,
},
body: roleDefinition,
})
.catch(ignoreHttp409Error)
Expand Down Expand Up @@ -104,6 +111,9 @@ export class RoleAndUserLoader<R extends Record<string, Role> = Record<string, R
.request({
method: 'POST',
path: `/internal/security/users/${username}`,
headers: {
...DEFAULT_HEADERS,
},
body: user,
})
.catch(ignoreHttp409Error)
Expand Down

0 comments on commit c0030da

Please sign in to comment.