1 | 'use strict';
|
2 |
|
3 | require('should');
|
4 | var Path = require('path');
|
5 | var IFNode = require('./..');
|
6 |
|
7 | describe('Connection server', function() {
|
8 | it('should create default connection server', function(done) {
|
9 | var app = IFNode({
|
10 | alias: 'default-server'
|
11 | });
|
12 | var connection = app.connection;
|
13 |
|
14 | connection.listen(function() {
|
15 | connection.close(function() {
|
16 | done();
|
17 | });
|
18 | });
|
19 | });
|
20 |
|
21 | it('should create default connection server with specific settings', function(done) {
|
22 | var app = IFNode({
|
23 | project_folder: Path.resolve(__dirname, '../examples/custom_connection_server'),
|
24 | alias: 'default-server-with-specific-settings',
|
25 | environment: 'default-server-with-specific-settings'
|
26 | });
|
27 | var connection = app.connection;
|
28 |
|
29 | connection.configure(function(server) {
|
30 | server.timeout = 0;
|
31 | });
|
32 |
|
33 | connection.listen(function() {
|
34 | connection.close(function() {
|
35 | done();
|
36 | });
|
37 | });
|
38 | });
|
39 |
|
40 | it('should create default PFX https connection server', function(done) {
|
41 | var app = IFNode({
|
42 | project_folder: Path.resolve(__dirname, '../examples/custom_connection_server'),
|
43 | alias: 'default-https-server',
|
44 | environment: 'default-https-pfx-server'
|
45 | });
|
46 | var connection = app.connection;
|
47 |
|
48 | connection.listen(function() {
|
49 | connection.close(function() {
|
50 | done();
|
51 | });
|
52 | });
|
53 | });
|
54 |
|
55 | it('should create default KEY/CERT https connection server', function(done) {
|
56 | var app = IFNode({
|
57 | project_folder: Path.resolve(__dirname, '../examples/custom_connection_server'),
|
58 | alias: 'default-https-server',
|
59 | environment: 'default-https-key-cert-server'
|
60 | });
|
61 | var connection = app.connection;
|
62 |
|
63 | connection.listen(function() {
|
64 | connection.close(function() {
|
65 | done();
|
66 | });
|
67 | });
|
68 | });
|
69 |
|
70 | it('should throw error for unexpected https connection server options', function() {
|
71 | (function() {
|
72 | IFNode({
|
73 | project_folder: Path.resolve(__dirname, '../examples/custom_connection_server'),
|
74 | alias: 'default-https-server',
|
75 | environment: 'default-https-wrong-type-server'
|
76 | });
|
77 | }).should.throw();
|
78 | });
|
79 |
|
80 | it('should create custom internal connection server', function(done) {
|
81 | var app = IFNode({
|
82 | alias: 'custom-server',
|
83 | project_folder: Path.resolve(__dirname, '../examples/custom_connection_server'),
|
84 | environment: 'custom-internal-server'
|
85 | });
|
86 |
|
87 | var connection = app.connection;
|
88 |
|
89 | connection.configure(function(server) {
|
90 | server.timeout = 0;
|
91 | });
|
92 | connection.listen(function() {
|
93 | connection.close(function() {
|
94 | done();
|
95 | });
|
96 | });
|
97 | });
|
98 |
|
99 | it('should create custom external connection server', function(done) {
|
100 | var app = IFNode({
|
101 | alias: 'custom-server',
|
102 | project_folder: Path.resolve(__dirname, '../examples/custom_connection_server'),
|
103 | environment: 'custom-external-server'
|
104 | });
|
105 |
|
106 | var connection = app.connection;
|
107 |
|
108 | connection.configure(function(server) {
|
109 | server.timeout = 0;
|
110 | });
|
111 | connection.listen(function() {
|
112 | connection.close(function() {
|
113 | done();
|
114 | });
|
115 | });
|
116 | });
|
117 |
|
118 | it('should throw error for non-existing connection server', function() {
|
119 | (function() {
|
120 | IFNode({
|
121 | alias: 'non-exists-server',
|
122 | project_folder: Path.resolve(__dirname, '../examples/custom_connection_server'),
|
123 | environment: 'non-exists-server'
|
124 | });
|
125 | }).should.throw();
|
126 | });
|
127 | });
|