mirror of
				https://github.com/NginxProxyManager/nginx-proxy-manager.git
				synced 2025-10-31 07:43:33 +00:00 
			
		
		
		
	Major update to cypress
- Updated cypress - Ground work for testing DNS certs in CI
This commit is contained in:
		
							
								
								
									
										20
									
								
								test/cypress/e2e/api/Health.cy.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								test/cypress/e2e/api/Health.cy.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| /// <reference types="Cypress" /> | ||||
|  | ||||
| describe('Basic API checks', () => { | ||||
| 	it('Should return a valid health payload', function () { | ||||
| 		cy.task('backendApiGet', { | ||||
| 			path: '/api/', | ||||
| 		}).then((data) => { | ||||
| 			// Check the swagger schema: | ||||
| 			cy.validateSwaggerSchema('get', 200, '/', data); | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	it('Should return a valid schema payload', function () { | ||||
| 		cy.task('backendApiGet', { | ||||
| 			path: '/api/schema', | ||||
| 		}).then((data) => { | ||||
| 			expect(data.openapi).to.be.equal('3.0.0'); | ||||
| 		}); | ||||
| 	}); | ||||
| }); | ||||
							
								
								
									
										48
									
								
								test/cypress/e2e/api/Hosts.cy.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								test/cypress/e2e/api/Hosts.cy.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| /// <reference types="Cypress" /> | ||||
|  | ||||
| describe('Hosts endpoints', () => { | ||||
| 	let token; | ||||
|  | ||||
| 	before(() => { | ||||
| 		cy.getToken().then((tok) => { | ||||
| 			token = tok; | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	it('Should be able to create a http host', function() { | ||||
| 		cy.task('backendApiPost', { | ||||
| 			token: token, | ||||
| 			path:  '/api/nginx/proxy-hosts', | ||||
| 			data:  { | ||||
| 				domain_names:   ['test.example.com'], | ||||
| 				forward_scheme: 'http', | ||||
| 				forward_host:   '1.1.1.1', | ||||
| 				forward_port:   80, | ||||
| 				access_list_id: '0', | ||||
| 				certificate_id: 0, | ||||
| 				meta:           { | ||||
| 					letsencrypt_agree: false, | ||||
| 					dns_challenge:     false | ||||
| 				}, | ||||
| 				advanced_config:         '', | ||||
| 				locations:               [], | ||||
| 				block_exploits:          false, | ||||
| 				caching_enabled:         false, | ||||
| 				allow_websocket_upgrade: false, | ||||
| 				http2_support:           false, | ||||
| 				hsts_enabled:            false, | ||||
| 				hsts_subdomains:         false, | ||||
| 				ssl_forced:              false | ||||
| 			} | ||||
| 		}).then((data) => { | ||||
| 			cy.validateSwaggerSchema('post', 201, '/nginx/proxy-hosts', data); | ||||
| 			expect(data).to.have.property('id'); | ||||
| 			expect(data.id).to.be.greaterThan(0); | ||||
| 			expect(data).to.have.property('enabled'); | ||||
| 			expect(data.enabled).to.be.greaterThan(0); | ||||
| 			expect(data).to.have.property('meta'); | ||||
| 			expect(typeof data.meta.nginx_online).to.be.equal('undefined'); | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| }); | ||||
							
								
								
									
										48
									
								
								test/cypress/e2e/api/Users.cy.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								test/cypress/e2e/api/Users.cy.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| /// <reference types="Cypress" /> | ||||
|  | ||||
| describe('Users endpoints', () => { | ||||
| 	let token; | ||||
|  | ||||
| 	before(() => { | ||||
| 		cy.getToken().then((tok) => { | ||||
| 			token = tok; | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	it('Should be able to get yourself', function() { | ||||
| 		cy.task('backendApiGet', { | ||||
| 			token: token, | ||||
| 			path:  '/api/users/me' | ||||
| 		}).then((data) => { | ||||
| 			cy.validateSwaggerSchema('get', 200, '/users/{userID}', data); | ||||
| 			expect(data).to.have.property('id'); | ||||
| 			expect(data.id).to.be.greaterThan(0); | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	it('Should be able to get all users', function() { | ||||
| 		cy.task('backendApiGet', { | ||||
| 			token: token, | ||||
| 			path:  '/api/users' | ||||
| 		}).then((data) => { | ||||
| 			cy.validateSwaggerSchema('get', 200, '/users', data); | ||||
| 			expect(data.length).to.be.greaterThan(0); | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	it('Should be able to update yourself', function() { | ||||
| 		cy.task('backendApiPut', { | ||||
| 			token: token, | ||||
| 			path:  '/api/users/me', | ||||
| 			data:  { | ||||
| 				name: 'changed name' | ||||
| 			} | ||||
| 		}).then((data) => { | ||||
| 			cy.validateSwaggerSchema('put', 200, '/users/{userID}', data); | ||||
| 			expect(data).to.have.property('id'); | ||||
| 			expect(data.id).to.be.greaterThan(0); | ||||
| 			expect(data.name).to.be.equal('changed name'); | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user