Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Test env API against our OpenAPI doc #205

Merged
merged 1 commit into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions docs/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,36 @@ paths:
application/json:
schema:
type: object
required:
- running_in_k8s
- user_string
- socket_namespace
- codewind_version
- os_platform
- tekton_dashboard_url
properties:
running_in_k8s:
type: boolean
example: false
user_string:
type: string
example: null
nullable: true
socket_namespace:
type: string
example: '/default'
codewind_version:
type: string
example: '/latest'
workspace_location:
type: string
example: '/home/user/codewind-workspace'
os_platform:
type: string
example: 'Linux'
tekton_dashboard_url:
type: string
example: '9.20.195.90.nip.io'
description: "Ingress URL of Tekton dashboard if it's available. On local Codewind, it is the empty string. May also be 'error' or 'not-installed'."
workspace_location:
type: string
example: '/home/user/codewind-workspace'
500:
description: Internal error occurred
/api/v1/projects:
Expand Down
17 changes: 6 additions & 11 deletions test/src/environment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,24 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
const chai = require('chai');
const chaiResValidator = require('chai-openapi-response-validator');

const reqService = require('../modules/request.service');
const { ADMIN_COOKIE, USING_K8S, DEFAULT_USER_NAME } = require('../config');
const { ADMIN_COOKIE, USING_K8S, DEFAULT_USER_NAME, pathToApiSpec } = require('../config');

const SOCKET_NAMESPACE = USING_K8S ? '/admin' : `/${DEFAULT_USER_NAME}`;

chai.use(chaiResValidator(pathToApiSpec));
chai.should();

describe('Environment API tests', function() {

it('should return expected environment properties', async function() {
const res = await reqService.chai
.get('/api/v1/environment')
.set('Cookie', ADMIN_COOKIE);

res.should.have.status(200);
res.should.have.ownProperty('body');
res.body.should.have.ownProperty('running_in_k8s', USING_K8S);
res.body.should.have.ownProperty('user_string');
res.body.should.have.ownProperty('socket_namespace', SOCKET_NAMESPACE);
res.body.should.have.ownProperty('codewind_version');
res.body.should.have.ownProperty('tekton_dashboard_url');
res.body.should.have.ownProperty('os_platform');
res.should.have.status(200).and.satisfyApiSpec;
res.body.running_in_k8s.should.equal(USING_K8S);
res.body.socket_namespace.should.equal(SOCKET_NAMESPACE);
if (!USING_K8S) res.body.should.have.ownProperty('workspace_location');
});
});