Commit graph

19 commits

Author SHA1 Message Date
Søren Louv-Jansen a5b5b8816b
[APM] Minimal e2e setup with Cypress (#43463)
* APM E2E with own package.json

* Ignore cypress folder

* Add cypress/apm as separate ts project

* Exclude from parent tsconfig

* Add p-limit as dep

* Fix readme

* Fix prettier command

* Resolve feedback

* Move date range into `loginAndWaitForPage`

* Remove redundant file

* Fixed lint errors

* Remove uneeded `data-cy` attributes

* Fix snapshots
2019-09-23 15:50:00 +02:00
Andrew Goldstein 95fc980203
[SIEM] Bootstrap Cypress Tests (#39588)
# Cypress Tests

The `siem/cypress` directory contains end to end tests (specific to the `SIEM` app) that execute via [Cypress](https://www.cypress.io/).

At present, these tests are only executed in a local development environment; they are **not** integrated in the Kibana CI infrastructure, and therefore do **not** run automatically when you submit a PR.

See the `Server and Authentication Requirements` section below for additional details.

## Organizing Tests and (Mock) Data

- Code and CSS selectors that may be re-used across tests should be added to `siem/cypress/integration/lib`, as described below
- Smoke Tests are located in `siem/cypress/integration/smoke_tests`
- Mocked responses from the server are located in `siem/cypress/fixtures`

### `cypress/integration/lib`

The `cypress/integration/lib` folder contains code intended to be re-used across many different tests.

- Files named `helpers.ts` (e.g. `siem/cypress/integration/lib/login/helpers.ts`) contain functions (e.g. `login`) that may be imported and invoked from multiple tests.

- Files named `selectors.ts` export CSS selectors for re-use. For example, `siem/cypress/integration/lib/login/selectors.ts` exports the following selector that matches the Username text area in the Kibana login page:

```
export const USERNAME = '[data-test-subj="loginUsername"]';
```

## Server and Authentication Requirements

The current version of the Smoke Tests require running a local Kibana server that connects to an instance of `elasticsearch`. A file named `config/kibana.dev.yml` like the example below is required to run the tests:

```yaml
elasticsearch:
  username: 'elastic'
  password: '<password>'
  hosts: ['https://<server>:9200']
```

The `username` and `password` from `config/kibana.dev.yml` will be read by the `login` test helper function when tests authenticate with Kibana.

See the `Running Tests Interactively` section for details.

## Running Tests Interactively

To run tests in interactively via the Cypress test runner:

1. Create and configure a `config/kibana.dev.yml`, as described in the `Server and Authentication Requirements` section above.

2. Start a local instance of the Kibana development server:

```
yarn start --no-base-path
```

3. Launch the Cypress interactive test runner:

```sh
cd x-pack/legacy/plugins/siem
yarn cypress:open
```

4. Click the `Run all specs` button in the Cypress test runner

![cypress](https://user-images.githubusercontent.com/4459398/60113545-39c54f00-972f-11e9-9c0c-5d28aecdf212.gif)

https://github.com/elastic/ingest-dev/issues/515
2019-06-27 17:28:33 -06:00
Ahmad Bamieh 8c8ef33d36
[i18n] move translations into NP plugin (#39177)
* new platform xpack plugin

* update env snapshot

* update all snapshots

* plugin service tests

* fix scripts/check_ts_projects.js

* update i18nrc

* run i18n_check
2019-06-26 11:29:11 +03:00
Court Ewing 2d171c92f5 Fix path references into and out of x-pack/legacy 2019-06-20 13:34:48 -04:00
igoristic 851b1f6955
Added promise with cancel with typescript support (#36293)
* Added promise with cancel

* Fixed imports

* Fixed an async unit test
2019-05-23 02:02:00 -04:00
Spencer 2e232c2e31
[@kbn/expect] "fork" expect.js into repo (#33761)
* [@kbn/expect] "fork" expect.js into repo

* [eslint] autofix references to expect.js

* [tslint] autofix all expect.js imports

* now that expect.js is in strict mode, avoid reassigning fn.length
2019-03-25 09:56:48 -07:00
Robert Monfera 45d6453fa7
Test: TypeScript type specification strength tests (#32905)
* Test: TypeScript type specification strength tests

* Chore: post-merge lint

* Post-merge conflict fix
2019-03-15 23:58:25 +01:00
Tiago Costa 9ca411c09e
Avoid transpiled files end up into the repo when building (#32069)
* fix(na): avoid transpiled files endup on repo when building xpack.

* docs(NA): added todo in order to remove added code when we run the upgrade to babel@7.

* fix(NA): include missing files from the x-pack build.
2019-03-01 00:26:42 +00:00
Spencer 4749c6aab6
[ts][ftr] improve types for ftr and expect.js, cleanup changes to tsconfig files (#31948)
In https://github.com/elastic/kibana/pull/31234 there were some extra changes that I've reverted, like use of the `tsconfig-paths` package to magically rewrite import statements to defy the standard node module resolution algorithm, the inclusion of several unnecessary options in the `test/tsconfig.json` file, and changes of the line-endings in the config files. This also brings a few enhancements from https://github.com/elastic/kibana/pull/30190 including a modularized version of the expect.js types, and options for explicit mappings for the PageObjects and services used in ftr tests.
2019-02-28 12:06:00 -08:00
Joe Fleming 696d125db6
chore: remove duplicate include path (#31499)
in x-pack tsconfig
2019-02-19 16:45:06 -07:00
Court Ewing 2ce51a5be5 Update paths to ui, server, deprecation, plugin_discovery in src/legacy
This commit accompanies the four that precede it. Rather than squash
them altogether, the four previous commits all do nothing except move
files to help avoid conflicts.
2019-02-11 10:41:37 -05:00
Tim Roes fb2f0569e2
Typings for saved object client (#29951)
* WIP typings for saved object client

* Move more files to TS

* type saved objects client

* clean up typings for saved object client

* tie typings form server and client for saved objects together

* add missing html import typing to x-pack

* Add missing buildSourcePatterns

* Removed accidental comma

* add typings for saved_object_client tests and fix test cases

* duplicate case_conversion helpers for the moment

* Address PR review

* Fix some documentation

* Replace ts-ignore by any imports

* Remove expect.js from test

* Add more typings to prevent CI failure
2019-02-07 12:43:17 +01:00
Josh Dover 888217dc0f
Upgrade Assistant Follow-ups (#29663)
* Check security privileges before allowing reindexing

* Add global readyForUpgrade flag for Cloud

* Add ml_settings to cluster_settings

* Generalize locking mechanism for stop/starting watcher

* Display ML/Watcher stopping/resuming steps in UI

* Fix type issues

* Handle security being disabled for privilege check

* Use xpack_main.info + add types

* Fix x-pack builds
2019-02-04 13:36:42 -06:00
tibmt fb6be4caed Translate Spaces component (#24411)
* Translate Spaces component

* fix one little error

* update Spaces component

* update translation of Spaces components

* Update snapshots

* update Space translation - intl type

* update Space translation - remove view/views id namespace

* rename ids

* use testing helper functions instead of shallow, render, mount from enzyme

* fix unit tests

* fix ts path for enzyme test helpers

* fix path to enzyme helpers test functions

* Update snapshots

* fix path to enzyme test helpers

* Remove unused dependency.
2018-11-15 11:09:12 +03:00
Leanid Shutau e9ff201be7
[I18n] Migrate enzyme helpers to TypeScript (#25108)
* [I18n] Migrate enzyme helpers to TypeScript

* Migrate src enzyme helpers

* Remove eslint comments
2018-11-06 15:56:37 +03:00
Brandon Kobel 8cbafdf5fe
Adding "Successfully logged out" page (#23890)
* Adding very basic place for the logged out page

* Redirecting to logged_out when we aren't using SLO

* Basing styles on the login styles

* Fixing linting errors

* Responding to PR feedback

* Fixing issue with the basepath and the login link

* Adding proper i18n prefix

* Updating unit tests
2018-11-01 05:33:32 -07:00
Larry Gregory 7d8ce7bc01
K7 Login screen (#23512)
This PR implements the K7 Login screen, as described in #20015

@ryankeairns @snide @kobelb 

## Login form
<img width="1310" alt="login" src="https://user-images.githubusercontent.com/3493255/46048123-d9e53d80-c0f5-11e8-9e56-acbe3a8f2b5a.png">

## Invalid credentials
![image](https://user-images.githubusercontent.com/3493255/46147388-621d2d00-c233-11e8-8a75-beba7bb5a2b2.png)


## Session expired
![image](https://user-images.githubusercontent.com/3493255/46147408-6fd2b280-c233-11e8-97c1-8acb7b2e0c06.png)


## No connection to Elasticsearch
![image](https://user-images.githubusercontent.com/3493255/46147515-adcfd680-c233-11e8-8ad4-3a21d2c06b2c.png)


## Insecure connection
![image](https://user-images.githubusercontent.com/3493255/46147433-8416af80-c233-11e8-82dc-6f32a5ec1bd0.png)



Closes #20015
2018-10-22 14:18:17 -04:00
Larry Gregory 1f38026731
Spaces Phase 1 (#21408)
### Review notes
This is generally ready for review. We are awaiting https://github.com/elastic/elasticsearch/issues/32777 to improve handling when users do not have any access to Kibana, but this should not hold up the overall review for this PR.

This PR is massive, there's no denying that. Here's what to focus on:
1) `x-pack/plugins/spaces`: This is, well, the Spaces plugin. Everything in here is brand new. The server code is arguably more important, but feel free to review whatever you see fit.
2) `x-pack/plugins/security`: There are large and significant changes here to allow Spaces to be securable. To save a bit of time, you are free to ignore changes in `x-pack/plugins/security/public`: These are the UI changes for the role management screen, which were previously reviewed by both us and the design team.
3) `x-pack/test/saved_object_api_integration` and `x-pack/test/spaces_api_integration`: These are the API test suites which verify functionality for:
     a) Both security and spaces enabled
     b) Only security enabled
     c) Only spaces enabled

What to ignore:
1) As mentioned above, you are free to ignore changes in `x-pack/plugins/security/public`
2) Changes to `kibana/src/server/*`: These changes are part of a [different PR that we're targeting against master](https://github.com/elastic/kibana/pull/23378) for easier review.

## Saved Objects Client Extensions
A bulk of the changes to the saved objects service are in the namespaces PR, but we have a couple of important changes included here.

### Priority Queue for wrappers
We have implemented a priority queue which allows plugins to specify the order in which their SOC wrapper should be applied: `kibana/src/server/saved_objects/service/lib/priority_collection.ts`. We are leveraging this to ensure that both the security SOC wrapper and the spaces SOC wrapper are applied in the correct order (more details below).

### Spaces SOC Wrapper
This wrapper is very simple, and it is only responsible for two things:
1) Prevent users from interacting with any `space` objects (use the Spaces client instead, described below)
2) Provide a `namespace` to the underlying Saved Objects Client, and ensure that no other wrappers/callers have provided a namespace. In order to accomplish this, the Spaces wrapper uses the priority queue to ensure that it is the last wrapper invoked before calling the underlying client.

### Security SOC Wrapper
This wrapper is responsible for performing authorization checks. It uses the priority queue to ensure that it is the first wrapper invoked. To say another way, if the authorization checks fail, then no other wrappers will be called, and the base client will not be called either. This wrapper authorizes users in one of two ways: RBAC or Legacy. More details on this are below.


### Examples:
`GET /s/marketing/api/saved_objects/index-pattern/foo`

**When both Security and Spaces are enabled:**
1) Saved objects API retrieves an instance of the SOC via `savedObjects.getScopedClient()`, and invokes its `get` function
2) The Security wrapper is invoked.
    a) Authorization checks are performed to ensure user can access this particular saved object at this space.
3) The Spaces wrapper is invoked.
   a) Spaces applies a `namespace` to be used by the underlying client
4) The underlying client/repository are invoked to retrieve the object from ES.

**When only Spaces are enabled:**
1) Saved objects API retrieves an instance of the SOC via `savedObjects.getScopedClient()`, and invokes its `get` function
2) The Spaces wrapper is invoked.
   a) Spaces applies a `namespace` to be used by the underlying client
3) The underlying client/repository are invoked to retrieve the object from ES.

**When only Security is enabled:**
(assume `/s/marketing` is no longer part of the request)
1) Saved objects API retrieves an instance of the SOC via `savedObjects.getScopedClient()`, and invokes its `get` function
2) The Security wrapper is invoked.
   a) Authorization checks are performed to ensure user can access this particular saved object globally.
3) The underlying client/repository are invoked to retrieve the object from ES.

## Authorization
Authorization changes for this project are centered around Saved Objects, and builds on the work introduced in RBAC Phase 1.

### Saved objects client
#### Security without spaces
When security is enabled, but spaces is disabled, then the authorization model behaves the same way as before: If the user is taking advantage of Kibana Privileges, then we check their privileges "globally" before proceeding. A "global" privilege check specifies `resources: ['*']` when calling the [ES _has_privileges api.](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html). Legacy users (non-rbac) will continue to use the underlying index privileges for authorization.

#### Security with spaces
When both plugins are enabled, then the authorization model becomes more fine-tuned. Rather than checking privileges globally, the privileges are checked against a specific resource that matches the user's active space. In order to accomplish this, the Security plugin needs to know if Spaces is enabled, and if so, it needs to ask Spaces for the user's active space. The subsequent call to the `ES _has_privileges api` would use `resources: ['space:marketing']` to verify that the user is authorized at the `marketing` space. Legacy users (non-rbac) will continue to use the underlying index privileges for authorization. **NOTE** The legacy behavior implies that those users will have access to all spaces. The read/write restrictions are still enforced, but there is no way to restrict access to a specific space for legacy auth users.

#### Spaces without security
No authorization performed. Everyone can access everything.

### Spaces client
Spaces, when enabled, prevents saved objects of type `space` from being CRUD'd via the Saved Objects Client. Instead, the only "approved" way to work with these objects is through the new Spaces client (`kibana/x-pack/plugins/spaces/lib/spaces_client.ts`).

When security is enabled, the Spaces client performs its own set of authorization checks before allowing the request to proceed. The Spaces client knows which authorization checks need to happen for a particular request, but it doesn't know _how_ to check privileges. To accomplish this, the spaces client will delegate the check security's authorization service.

#### FAQ: Why oh why can't you used the Saved Objects Client instead!?
That's a great question! We did this primarily to simplify the authorization model (at least for our initial release). Accessing regular saved objects follows a predictible authorization pattern (described above). Spaces themselves inform the authorization model, and this interplay would have greatly increased the complexity. We are brainstorming ideas to obselete the Spaces client in favor of using the Saved Objects Client everywhere, but that's certainly out of scope for this release.



## Test Coverage
### Saved Objects API
A bulk of the changes to enable spaces are centered around saved objects, so we have spent a majority of our time automating tests against the saved objects api.

**`x-pack/test/saved_object_api_integration/`** contains the test suites for the saved objects api. There is a `common/suites` subfolder which contains a bulk of the test logic. The suites defined here are used in the following test configurations:
1) Spaces only: `./spaces_only`
2) Security and spaces: `./security_and_spaces`
3) Security only: `./security_only`

Each of these test configurations will start up ES/Kibana with the appropriate license and plugin set. Each set runs through the entire test suite described in `common/suites`. Each test with in each suite is run multiple times with different inputs, to test the various permutations of authentication, authorization type (legacy vs RBAC), space-level privileges, and the user's active space.  

### Spaces API
Spaces provides an experimental public API.

**`x-pack/test/spaces_api_integration`** contains the test suites for the Spaces API. Similar to the Saved Objects API tests described above, there is a `common/suites` folder which contains a bulk of the test logic. The suites defined here are used in the following test configurations:
1) Spaces only: `./spaces_only`
2) Security and spaces: `./security_and_spaces`


### Role Management UI
We did not provide any new functional UI tests for role management, but the existing suite was updated to accomidate the screen rewrite.

We do have a decent suite of jest unit tests for the various components that make up the new role management screen. They're nested within `kibana/x-pack/plugins/security/public/views/management/edit_role`

### Spaces Management UI
We did not provide any new functional UI tests for spaces management, but the components that make up the screens are well-tested, and can be found within `kibana/x-pack/plugins/spaces/public/views/management/edit_space`

### Spaces Functional UI Tests
There are a couple of UI tests that verify _basic_ functionality. They assert that a user can login, select a space, and then choose a different space once inside: `kibana/x-pack/test/functional/apps/spaces`



## Reference

Notable child PRs are listed below for easier digesting. Note that some of these PRs are built on other PRs, so the deltas in the links below may be outdated. Cross reference with this PR when in doubt.

### UI
- Reactify Role Management Screen: https://github.com/elastic/kibana/pull/19035
- Space Aware Privileges UI: https://github.com/elastic/kibana/pull/21049
- Space Selector (in Kibana Nav): https://github.com/elastic/kibana/pull/19497
- Recently viewed Widget: https://github.com/elastic/kibana/pull/22492
- Support Space rename/delete: https://github.com/elastic/kibana/pull/22586

### Saved Objects Client
- ~~Space Aware Saved Objects: https://github.com/elastic/kibana/pull/18862~~
- ~~Add Space ID to document id: https://github.com/elastic/kibana/pull/21372~~
- Saved object namespaces (supercedes #18862 and #21372):  https://github.com/elastic/kibana/pull/22357
- Securing saved objects: https://github.com/elastic/kibana/pull/21995
- Dedicated Spaces client (w/ security): https://github.com/elastic/kibana/pull/21995

### Other
- Public Spaces API (experimental): https://github.com/elastic/kibana/pull/22501
- Telemetry: https://github.com/elastic/kibana/pull/20581
- Reporting: https://github.com/elastic/kibana/pull/21457
- Spencer's original Spaces work: https://github.com/elastic/kibana/pull/18664
- Expose `spaceId` to "Add Data" tutorials: https://github.com/elastic/kibana/pull/22760

Closes #18948 

"Release Note: Create spaces within Kibana to organize dashboards, visualizations, and other saved objects. Secure access to each space when X-Pack Security is enabled"
2018-10-01 07:09:33 -04:00
Spencer c6112067fc
[typescript] add typescript support for the server and browser (#19104)
* [typescript] add typescript support for the server and browser

* [ts-jest] upgrade to latest version

* [jest] support test.tsx files

* [jest/ts] modify `ts-jest.tsConfigFile` config based on filePath

* [types] use correct major version of minimatch types

* [jest] add ts support to x-pack jest config

* [ts/projects] fix tsconfig.json not found error message

* [optimizer/ts] use lowercase jsx option

* [tsconfig] remove ui/* alias

* [plguin-helpers] remove mention of `buildSourcePatterns`

* [plugin-helpers] expect typescript to be a devDep

* [dev/build] place transpile tasks next to each other

* [ts/x-pack] add common and server directories to ts project

* [dev/ts/project] use a limited set of globs to find tsconfig files
2018-05-18 10:54:57 -07:00