##// END OF EJS Templates
js: fixed usage of minimized JS
marcink -
r4023:2f0df463 default
parent child Browse files
Show More
@@ -1,296 +1,296 b''
1 # Nix environment for the community edition
1 # Nix environment for the community edition
2 #
2 #
3 # This shall be as lean as possible, just producing the enterprise-ce
3 # This shall be as lean as possible, just producing the enterprise-ce
4 # derivation. For advanced tweaks to pimp up the development environment we use
4 # derivation. For advanced tweaks to pimp up the development environment we use
5 # "shell.nix" so that it does not have to clutter this file.
5 # "shell.nix" so that it does not have to clutter this file.
6 #
6 #
7 # Configuration, set values in "~/.nixpkgs/config.nix".
7 # Configuration, set values in "~/.nixpkgs/config.nix".
8 # example
8 # example
9 # {
9 # {
10 # # Thoughts on how to configure the dev environment
10 # # Thoughts on how to configure the dev environment
11 # rc = {
11 # rc = {
12 # codeInternalUrl = "https://usr:token@code.rhodecode.com/internal";
12 # codeInternalUrl = "https://usr:token@code.rhodecode.com/internal";
13 # sources = {
13 # sources = {
14 # rhodecode-vcsserver = "/home/user/work/rhodecode-vcsserver";
14 # rhodecode-vcsserver = "/home/user/work/rhodecode-vcsserver";
15 # rhodecode-enterprise-ce = "/home/user/work/rhodecode-enterprise-ce";
15 # rhodecode-enterprise-ce = "/home/user/work/rhodecode-enterprise-ce";
16 # rhodecode-enterprise-ee = "/home/user/work/rhodecode-enterprise-ee";
16 # rhodecode-enterprise-ee = "/home/user/work/rhodecode-enterprise-ee";
17 # };
17 # };
18 # };
18 # };
19 # }
19 # }
20
20
21 args@
21 args@
22 { system ? builtins.currentSystem
22 { system ? builtins.currentSystem
23 , pythonPackages ? "python27Packages"
23 , pythonPackages ? "python27Packages"
24 , pythonExternalOverrides ? self: super: {}
24 , pythonExternalOverrides ? self: super: {}
25 , doCheck ? false
25 , doCheck ? false
26 , ...
26 , ...
27 }:
27 }:
28
28
29 let
29 let
30 pkgs_ = args.pkgs or (import <nixpkgs> { inherit system; });
30 pkgs_ = args.pkgs or (import <nixpkgs> { inherit system; });
31 in
31 in
32
32
33 let
33 let
34 pkgs = import <nixpkgs> {
34 pkgs = import <nixpkgs> {
35 overlays = [
35 overlays = [
36 (import ./pkgs/overlays.nix)
36 (import ./pkgs/overlays.nix)
37 ];
37 ];
38 inherit
38 inherit
39 (pkgs_)
39 (pkgs_)
40 system;
40 system;
41 };
41 };
42
42
43 # Works with the new python-packages, still can fallback to the old
43 # Works with the new python-packages, still can fallback to the old
44 # variant.
44 # variant.
45 basePythonPackagesUnfix = basePythonPackages.__unfix__ or (
45 basePythonPackagesUnfix = basePythonPackages.__unfix__ or (
46 self: basePythonPackages.override (a: { inherit self; }));
46 self: basePythonPackages.override (a: { inherit self; }));
47
47
48 # Evaluates to the last segment of a file system path.
48 # Evaluates to the last segment of a file system path.
49 basename = path: with pkgs.lib; last (splitString "/" path);
49 basename = path: with pkgs.lib; last (splitString "/" path);
50
50
51 # source code filter used as arugment to builtins.filterSource.
51 # source code filter used as arugment to builtins.filterSource.
52 src-filter = path: type: with pkgs.lib;
52 src-filter = path: type: with pkgs.lib;
53 let
53 let
54 ext = last (splitString "." path);
54 ext = last (splitString "." path);
55 in
55 in
56 !builtins.elem (basename path) [
56 !builtins.elem (basename path) [
57 ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev"
57 ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev"
58 "node_modules" "node_binaries"
58 "node_modules" "node_binaries"
59 "build" "data" "result" "tmp"] &&
59 "build" "data" "result" "tmp"] &&
60 !builtins.elem ext ["egg-info" "pyc"] &&
60 !builtins.elem ext ["egg-info" "pyc"] &&
61 # TODO: johbo: This check is wrong, since "path" contains an absolute path,
61 # TODO: johbo: This check is wrong, since "path" contains an absolute path,
62 # it would still be good to restore it since we want to ignore "result-*".
62 # it would still be good to restore it since we want to ignore "result-*".
63 !hasPrefix "result" path;
63 !hasPrefix "result" path;
64
64
65 sources =
65 sources =
66 let
66 let
67 inherit
67 inherit
68 (pkgs.lib)
68 (pkgs.lib)
69 all
69 all
70 isString
70 isString
71 attrValues;
71 attrValues;
72 sourcesConfig = pkgs.config.rc.sources or {};
72 sourcesConfig = pkgs.config.rc.sources or {};
73 in
73 in
74 # Ensure that sources are configured as strings. Using a path
74 # Ensure that sources are configured as strings. Using a path
75 # would result in a copy into the nix store.
75 # would result in a copy into the nix store.
76 assert all isString (attrValues sourcesConfig);
76 assert all isString (attrValues sourcesConfig);
77 sourcesConfig;
77 sourcesConfig;
78
78
79 version = builtins.readFile "${rhodecode-enterprise-ce-src}/rhodecode/VERSION";
79 version = builtins.readFile "${rhodecode-enterprise-ce-src}/rhodecode/VERSION";
80 rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.;
80 rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.;
81
81
82 nodeEnv = import ./pkgs/node-default.nix {
82 nodeEnv = import ./pkgs/node-default.nix {
83 inherit
83 inherit
84 pkgs
84 pkgs
85 system;
85 system;
86 };
86 };
87 nodeDependencies = nodeEnv.shell.nodeDependencies;
87 nodeDependencies = nodeEnv.shell.nodeDependencies;
88
88
89 rhodecode-testdata-src = sources.rhodecode-testdata or (
89 rhodecode-testdata-src = sources.rhodecode-testdata or (
90 pkgs.fetchhg {
90 pkgs.fetchhg {
91 url = "https://code.rhodecode.com/upstream/rc_testdata";
91 url = "https://code.rhodecode.com/upstream/rc_testdata";
92 rev = "v0.10.0";
92 rev = "v0.10.0";
93 sha256 = "0zn9swwvx4vgw4qn8q3ri26vvzgrxn15x6xnjrysi1bwmz01qjl0";
93 sha256 = "0zn9swwvx4vgw4qn8q3ri26vvzgrxn15x6xnjrysi1bwmz01qjl0";
94 });
94 });
95
95
96 rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" {
96 rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" {
97 inherit
97 inherit
98 doCheck
98 doCheck
99 pkgs
99 pkgs
100 pythonPackages;
100 pythonPackages;
101 };
101 };
102
102
103 pythonLocalOverrides = self: super: {
103 pythonLocalOverrides = self: super: {
104 rhodecode-enterprise-ce =
104 rhodecode-enterprise-ce =
105 let
105 let
106 linkNodePackages = ''
106 linkNodePackages = ''
107 export RHODECODE_CE_PATH=${rhodecode-enterprise-ce-src}
107 export RHODECODE_CE_PATH=${rhodecode-enterprise-ce-src}
108
108
109 echo "[BEGIN]: Link node packages and binaries"
109 echo "[BEGIN]: Link node packages and binaries"
110 # johbo: Linking individual packages allows us to run "npm install"
110 # johbo: Linking individual packages allows us to run "npm install"
111 # inside of a shell to try things out. Re-entering the shell will
111 # inside of a shell to try things out. Re-entering the shell will
112 # restore a clean environment.
112 # restore a clean environment.
113 rm -fr node_modules
113 rm -fr node_modules
114 mkdir node_modules
114 mkdir node_modules
115 ln -s ${nodeDependencies}/lib/node_modules/* node_modules/
115 ln -s ${nodeDependencies}/lib/node_modules/* node_modules/
116 export NODE_PATH=./node_modules
116 export NODE_PATH=./node_modules
117
117
118 rm -fr node_binaries
118 rm -fr node_binaries
119 mkdir node_binaries
119 mkdir node_binaries
120 ln -s ${nodeDependencies}/bin/* node_binaries/
120 ln -s ${nodeDependencies}/bin/* node_binaries/
121 echo "[DONE ]: Link node packages and binaries"
121 echo "[DONE ]: Link node packages and binaries"
122 '';
122 '';
123
123
124 releaseName = "RhodeCodeEnterpriseCE-${version}";
124 releaseName = "RhodeCodeEnterpriseCE-${version}";
125 in super.rhodecode-enterprise-ce.override (attrs: {
125 in super.rhodecode-enterprise-ce.override (attrs: {
126 inherit
126 inherit
127 doCheck
127 doCheck
128 version;
128 version;
129
129
130 name = "rhodecode-enterprise-ce-${version}";
130 name = "rhodecode-enterprise-ce-${version}";
131 releaseName = releaseName;
131 releaseName = releaseName;
132 src = rhodecode-enterprise-ce-src;
132 src = rhodecode-enterprise-ce-src;
133 dontStrip = true; # prevent strip, we don't need it.
133 dontStrip = true; # prevent strip, we don't need it.
134
134
135 # expose following attributed outside
135 # expose following attributed outside
136 passthru = {
136 passthru = {
137 inherit
137 inherit
138 rhodecode-testdata
138 rhodecode-testdata
139 linkNodePackages
139 linkNodePackages
140 myPythonPackagesUnfix
140 myPythonPackagesUnfix
141 pythonLocalOverrides
141 pythonLocalOverrides
142 pythonCommunityOverrides;
142 pythonCommunityOverrides;
143
143
144 pythonPackages = self;
144 pythonPackages = self;
145 };
145 };
146
146
147 buildInputs =
147 buildInputs =
148 attrs.buildInputs or [] ++ [
148 attrs.buildInputs or [] ++ [
149 rhodecode-testdata
149 rhodecode-testdata
150 ];
150 ];
151
151
152 #NOTE: option to inject additional propagatedBuildInputs
152 #NOTE: option to inject additional propagatedBuildInputs
153 propagatedBuildInputs =
153 propagatedBuildInputs =
154 attrs.propagatedBuildInputs or [] ++ [
154 attrs.propagatedBuildInputs or [] ++ [
155
155
156 ];
156 ];
157
157
158 LC_ALL = "en_US.UTF-8";
158 LC_ALL = "en_US.UTF-8";
159 LOCALE_ARCHIVE =
159 LOCALE_ARCHIVE =
160 if pkgs.stdenv.isLinux
160 if pkgs.stdenv.isLinux
161 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
161 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
162 else "";
162 else "";
163
163
164 # Add bin directory to path so that tests can find 'rhodecode'.
164 # Add bin directory to path so that tests can find 'rhodecode'.
165 preCheck = ''
165 preCheck = ''
166 export PATH="$out/bin:$PATH"
166 export PATH="$out/bin:$PATH"
167 '';
167 '';
168
168
169 # custom check phase for testing
169 # custom check phase for testing
170 checkPhase = ''
170 checkPhase = ''
171 runHook preCheck
171 runHook preCheck
172 PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=rhodecode --cov-report=term-missing rhodecode
172 PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=rhodecode --cov-report=term-missing rhodecode
173 runHook postCheck
173 runHook postCheck
174 '';
174 '';
175
175
176 postCheck = ''
176 postCheck = ''
177 echo "Cleanup of rhodecode/tests"
177 echo "Cleanup of rhodecode/tests"
178 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
178 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
179 '';
179 '';
180
180
181 preBuild = ''
181 preBuild = ''
182 echo "[BEGIN]: Building frontend assets"
182 echo "[BEGIN]: Building frontend assets"
183 ${linkNodePackages}
183 ${linkNodePackages}
184 make web-build
184 make web-build
185 rm -fr node_modules
185 rm -fr node_modules
186 rm -fr node_binaries
186 rm -fr node_binaries
187 echo "[DONE ]: Building frontend assets"
187 echo "[DONE ]: Building frontend assets"
188 '';
188 '';
189
189
190 postInstall = ''
190 postInstall = ''
191 # check required files
191 # check required files
192 STATIC_CHECK="/robots.txt /502.html
192 STATIC_CHECK="/robots.txt /502.html
193 /js/scripts.js /js/rhodecode-components.js
193 /js/scripts.min.js /js/rhodecode-components.js
194 /css/style.css /css/style-polymer.css /css/style-ipython.css"
194 /css/style.css /css/style-polymer.css /css/style-ipython.css"
195
195
196 for file in $STATIC_CHECK;
196 for file in $STATIC_CHECK;
197 do
197 do
198 if [ ! -f rhodecode/public/$file ]; then
198 if [ ! -f rhodecode/public/$file ]; then
199 echo "Missing $file"
199 echo "Missing $file"
200 exit 1
200 exit 1
201 fi
201 fi
202 done
202 done
203
203
204 echo "Writing enterprise-ce meta information for rccontrol to nix-support/rccontrol"
204 echo "Writing enterprise-ce meta information for rccontrol to nix-support/rccontrol"
205 mkdir -p $out/nix-support/rccontrol
205 mkdir -p $out/nix-support/rccontrol
206 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
206 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
207 echo "[DONE ]: enterprise-ce meta information for rccontrol written"
207 echo "[DONE ]: enterprise-ce meta information for rccontrol written"
208
208
209 mkdir -p $out/etc
209 mkdir -p $out/etc
210 cp configs/production.ini $out/etc
210 cp configs/production.ini $out/etc
211 echo "[DONE ]: saved enterprise-ce production.ini into $out/etc"
211 echo "[DONE ]: saved enterprise-ce production.ini into $out/etc"
212
212
213 cp -Rf rhodecode/config/rcextensions $out/etc/rcextensions.tmpl
213 cp -Rf rhodecode/config/rcextensions $out/etc/rcextensions.tmpl
214 echo "[DONE ]: saved enterprise-ce rcextensions into $out/etc/rcextensions.tmpl"
214 echo "[DONE ]: saved enterprise-ce rcextensions into $out/etc/rcextensions.tmpl"
215
215
216 # python based programs need to be wrapped
216 # python based programs need to be wrapped
217 mkdir -p $out/bin
217 mkdir -p $out/bin
218
218
219 # required binaries from dependencies
219 # required binaries from dependencies
220 ln -s ${self.supervisor}/bin/supervisorctl $out/bin/
220 ln -s ${self.supervisor}/bin/supervisorctl $out/bin/
221 ln -s ${self.supervisor}/bin/supervisord $out/bin/
221 ln -s ${self.supervisor}/bin/supervisord $out/bin/
222 ln -s ${self.pastescript}/bin/paster $out/bin/
222 ln -s ${self.pastescript}/bin/paster $out/bin/
223 ln -s ${self.channelstream}/bin/channelstream $out/bin/
223 ln -s ${self.channelstream}/bin/channelstream $out/bin/
224 ln -s ${self.celery}/bin/celery $out/bin/
224 ln -s ${self.celery}/bin/celery $out/bin/
225 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
225 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
226 ln -s ${self.pyramid}/bin/prequest $out/bin/
226 ln -s ${self.pyramid}/bin/prequest $out/bin/
227 ln -s ${self.pyramid}/bin/pserve $out/bin/
227 ln -s ${self.pyramid}/bin/pserve $out/bin/
228
228
229 echo "[DONE ]: created symlinks into $out/bin"
229 echo "[DONE ]: created symlinks into $out/bin"
230 DEPS="$out/bin/supervisorctl \
230 DEPS="$out/bin/supervisorctl \
231 $out/bin/supervisord \
231 $out/bin/supervisord \
232 $out/bin/paster \
232 $out/bin/paster \
233 $out/bin/channelstream \
233 $out/bin/channelstream \
234 $out/bin/celery \
234 $out/bin/celery \
235 $out/bin/gunicorn \
235 $out/bin/gunicorn \
236 $out/bin/prequest \
236 $out/bin/prequest \
237 $out/bin/pserve"
237 $out/bin/pserve"
238
238
239 # wrap only dependency scripts, they require to have full PYTHONPATH set
239 # wrap only dependency scripts, they require to have full PYTHONPATH set
240 # to be able to import all packages
240 # to be able to import all packages
241 for file in $DEPS;
241 for file in $DEPS;
242 do
242 do
243 wrapProgram $file \
243 wrapProgram $file \
244 --prefix PATH : $PATH \
244 --prefix PATH : $PATH \
245 --prefix PYTHONPATH : $PYTHONPATH \
245 --prefix PYTHONPATH : $PYTHONPATH \
246 --set PYTHONHASHSEED random
246 --set PYTHONHASHSEED random
247 done
247 done
248
248
249 echo "[DONE ]: enterprise-ce binary wrapping"
249 echo "[DONE ]: enterprise-ce binary wrapping"
250
250
251 # rhodecode-tools don't need wrapping
251 # rhodecode-tools don't need wrapping
252 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
252 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
253
253
254 # expose sources of CE
254 # expose sources of CE
255 ln -s $out $out/etc/rhodecode_enterprise_ce_source
255 ln -s $out $out/etc/rhodecode_enterprise_ce_source
256
256
257 # expose static files folder
257 # expose static files folder
258 cp -Rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/public/ $out/etc/static
258 cp -Rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/public/ $out/etc/static
259 chmod 755 -R $out/etc/static
259 chmod 755 -R $out/etc/static
260
260
261 '';
261 '';
262 });
262 });
263
263
264 };
264 };
265
265
266 basePythonPackages = with builtins;
266 basePythonPackages = with builtins;
267 if isAttrs pythonPackages then
267 if isAttrs pythonPackages then
268 pythonPackages
268 pythonPackages
269 else
269 else
270 getAttr pythonPackages pkgs;
270 getAttr pythonPackages pkgs;
271
271
272 pythonGeneratedPackages = import ./pkgs/python-packages.nix {
272 pythonGeneratedPackages = import ./pkgs/python-packages.nix {
273 inherit
273 inherit
274 pkgs;
274 pkgs;
275 inherit
275 inherit
276 (pkgs)
276 (pkgs)
277 fetchurl
277 fetchurl
278 fetchgit
278 fetchgit
279 fetchhg;
279 fetchhg;
280 };
280 };
281
281
282 pythonCommunityOverrides = import ./pkgs/python-packages-overrides.nix {
282 pythonCommunityOverrides = import ./pkgs/python-packages-overrides.nix {
283 inherit pkgs basePythonPackages;
283 inherit pkgs basePythonPackages;
284 };
284 };
285
285
286 # Apply all overrides and fix the final package set
286 # Apply all overrides and fix the final package set
287 myPythonPackagesUnfix = with pkgs.lib;
287 myPythonPackagesUnfix = with pkgs.lib;
288 (extends pythonExternalOverrides
288 (extends pythonExternalOverrides
289 (extends pythonLocalOverrides
289 (extends pythonLocalOverrides
290 (extends pythonCommunityOverrides
290 (extends pythonCommunityOverrides
291 (extends pythonGeneratedPackages
291 (extends pythonGeneratedPackages
292 basePythonPackagesUnfix))));
292 basePythonPackagesUnfix))));
293
293
294 myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix);
294 myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix);
295
295
296 in myPythonPackages.rhodecode-enterprise-ce
296 in myPythonPackages.rhodecode-enterprise-ce
@@ -1,141 +1,141 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2010-2019 RhodeCode GmbH
3 # Copyright (C) 2010-2019 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21
21
22 import pytest
22 import pytest
23
23
24 import rhodecode
24 import rhodecode
25 from rhodecode.model.db import Repository
25 from rhodecode.model.db import Repository
26 from rhodecode.model.meta import Session
26 from rhodecode.model.meta import Session
27 from rhodecode.model.repo import RepoModel
27 from rhodecode.model.repo import RepoModel
28 from rhodecode.model.repo_group import RepoGroupModel
28 from rhodecode.model.repo_group import RepoGroupModel
29 from rhodecode.model.settings import SettingsModel
29 from rhodecode.model.settings import SettingsModel
30 from rhodecode.tests import TestController
30 from rhodecode.tests import TestController
31 from rhodecode.tests.fixture import Fixture
31 from rhodecode.tests.fixture import Fixture
32 from rhodecode.lib import helpers as h
32 from rhodecode.lib import helpers as h
33
33
34 fixture = Fixture()
34 fixture = Fixture()
35
35
36
36
37 def route_path(name, **kwargs):
37 def route_path(name, **kwargs):
38 return {
38 return {
39 'home': '/',
39 'home': '/',
40 'repo_group_home': '/{repo_group_name}'
40 'repo_group_home': '/{repo_group_name}'
41 }[name].format(**kwargs)
41 }[name].format(**kwargs)
42
42
43
43
44 class TestHomeController(TestController):
44 class TestHomeController(TestController):
45
45
46 def test_index(self):
46 def test_index(self):
47 self.log_user()
47 self.log_user()
48 response = self.app.get(route_path('home'))
48 response = self.app.get(route_path('home'))
49 # if global permission is set
49 # if global permission is set
50 response.mustcontain('New Repository')
50 response.mustcontain('New Repository')
51
51
52 # search for objects inside the JavaScript JSON
52 # search for objects inside the JavaScript JSON
53 for repo in Repository.getAll():
53 for repo in Repository.getAll():
54 response.mustcontain('"name_raw": "%s"' % repo.repo_name)
54 response.mustcontain('"name_raw": "%s"' % repo.repo_name)
55
55
56 def test_index_contains_statics_with_ver(self):
56 def test_index_contains_statics_with_ver(self):
57 from rhodecode.lib.base import calculate_version_hash
57 from rhodecode.lib.base import calculate_version_hash
58
58
59 self.log_user()
59 self.log_user()
60 response = self.app.get(route_path('home'))
60 response = self.app.get(route_path('home'))
61
61
62 rhodecode_version_hash = calculate_version_hash(
62 rhodecode_version_hash = calculate_version_hash(
63 {'beaker.session.secret': 'test-rc-uytcxaz'})
63 {'beaker.session.secret': 'test-rc-uytcxaz'})
64 response.mustcontain('style.css?ver={0}'.format(rhodecode_version_hash))
64 response.mustcontain('style.css?ver={0}'.format(rhodecode_version_hash))
65 response.mustcontain('scripts.js?ver={0}'.format(rhodecode_version_hash))
65 response.mustcontain('scripts.min.js?ver={0}'.format(rhodecode_version_hash))
66
66
67 def test_index_contains_backend_specific_details(self, backend):
67 def test_index_contains_backend_specific_details(self, backend):
68 self.log_user()
68 self.log_user()
69 response = self.app.get(route_path('home'))
69 response = self.app.get(route_path('home'))
70 tip = backend.repo.get_commit().raw_id
70 tip = backend.repo.get_commit().raw_id
71
71
72 # html in javascript variable:
72 # html in javascript variable:
73 response.mustcontain(r'<i class=\"icon-%s\"' % (backend.alias, ))
73 response.mustcontain(r'<i class=\"icon-%s\"' % (backend.alias, ))
74 response.mustcontain(r'href=\"/%s\"' % (backend.repo_name, ))
74 response.mustcontain(r'href=\"/%s\"' % (backend.repo_name, ))
75
75
76 response.mustcontain("""/%s/changeset/%s""" % (backend.repo_name, tip))
76 response.mustcontain("""/%s/changeset/%s""" % (backend.repo_name, tip))
77 response.mustcontain("""Added a symlink""")
77 response.mustcontain("""Added a symlink""")
78
78
79 def test_index_with_anonymous_access_disabled(self):
79 def test_index_with_anonymous_access_disabled(self):
80 with fixture.anon_access(False):
80 with fixture.anon_access(False):
81 response = self.app.get(route_path('home'), status=302)
81 response = self.app.get(route_path('home'), status=302)
82 assert 'login' in response.location
82 assert 'login' in response.location
83
83
84 def test_index_page_on_groups(self, autologin_user, repo_group):
84 def test_index_page_on_groups(self, autologin_user, repo_group):
85 response = self.app.get(route_path('repo_group_home', repo_group_name='gr1'))
85 response = self.app.get(route_path('repo_group_home', repo_group_name='gr1'))
86 response.mustcontain("gr1/repo_in_group")
86 response.mustcontain("gr1/repo_in_group")
87
87
88 def test_index_page_on_group_with_trailing_slash(
88 def test_index_page_on_group_with_trailing_slash(
89 self, autologin_user, repo_group):
89 self, autologin_user, repo_group):
90 response = self.app.get(route_path('repo_group_home', repo_group_name='gr1') + '/')
90 response = self.app.get(route_path('repo_group_home', repo_group_name='gr1') + '/')
91 response.mustcontain("gr1/repo_in_group")
91 response.mustcontain("gr1/repo_in_group")
92
92
93 @pytest.fixture(scope='class')
93 @pytest.fixture(scope='class')
94 def repo_group(self, request):
94 def repo_group(self, request):
95 gr = fixture.create_repo_group('gr1')
95 gr = fixture.create_repo_group('gr1')
96 fixture.create_repo(name='gr1/repo_in_group', repo_group=gr)
96 fixture.create_repo(name='gr1/repo_in_group', repo_group=gr)
97
97
98 @request.addfinalizer
98 @request.addfinalizer
99 def cleanup():
99 def cleanup():
100 RepoModel().delete('gr1/repo_in_group')
100 RepoModel().delete('gr1/repo_in_group')
101 RepoGroupModel().delete(repo_group='gr1', force_delete=True)
101 RepoGroupModel().delete(repo_group='gr1', force_delete=True)
102 Session().commit()
102 Session().commit()
103
103
104 def test_index_with_name_with_tags(self, user_util, autologin_user):
104 def test_index_with_name_with_tags(self, user_util, autologin_user):
105 user = user_util.create_user()
105 user = user_util.create_user()
106 username = user.username
106 username = user.username
107 user.name = '<img src="/image1" onload="alert(\'Hello, World!\');">'
107 user.name = '<img src="/image1" onload="alert(\'Hello, World!\');">'
108 user.lastname = '#"><img src=x onerror=prompt(document.cookie);>'
108 user.lastname = '#"><img src=x onerror=prompt(document.cookie);>'
109
109
110 Session().add(user)
110 Session().add(user)
111 Session().commit()
111 Session().commit()
112 user_util.create_repo(owner=username)
112 user_util.create_repo(owner=username)
113
113
114 response = self.app.get(route_path('home'))
114 response = self.app.get(route_path('home'))
115 response.mustcontain(h.html_escape(user.first_name))
115 response.mustcontain(h.html_escape(user.first_name))
116 response.mustcontain(h.html_escape(user.last_name))
116 response.mustcontain(h.html_escape(user.last_name))
117
117
118 @pytest.mark.parametrize("name, state", [
118 @pytest.mark.parametrize("name, state", [
119 ('Disabled', False),
119 ('Disabled', False),
120 ('Enabled', True),
120 ('Enabled', True),
121 ])
121 ])
122 def test_index_show_version(self, autologin_user, name, state):
122 def test_index_show_version(self, autologin_user, name, state):
123 version_string = 'RhodeCode Enterprise %s' % rhodecode.__version__
123 version_string = 'RhodeCode Enterprise %s' % rhodecode.__version__
124
124
125 sett = SettingsModel().create_or_update_setting(
125 sett = SettingsModel().create_or_update_setting(
126 'show_version', state, 'bool')
126 'show_version', state, 'bool')
127 Session().add(sett)
127 Session().add(sett)
128 Session().commit()
128 Session().commit()
129 SettingsModel().invalidate_settings_cache()
129 SettingsModel().invalidate_settings_cache()
130
130
131 response = self.app.get(route_path('home'))
131 response = self.app.get(route_path('home'))
132 if state is True:
132 if state is True:
133 response.mustcontain(version_string)
133 response.mustcontain(version_string)
134 if state is False:
134 if state is False:
135 response.mustcontain(no=[version_string])
135 response.mustcontain(no=[version_string])
136
136
137 def test_logout_form_contains_csrf(self, autologin_user, csrf_token):
137 def test_logout_form_contains_csrf(self, autologin_user, csrf_token):
138 response = self.app.get(route_path('home'))
138 response = self.app.get(route_path('home'))
139 assert_response = response.assert_response()
139 assert_response = response.assert_response()
140 element = assert_response.get_element('.logout #csrf_token')
140 element = assert_response.get_element('.logout #csrf_token')
141 assert element.value == csrf_token
141 assert element.value == csrf_token
@@ -1,93 +1,93 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <!DOCTYPE html>
2 <!DOCTYPE html>
3 <html xmlns="http://www.w3.org/1999/xhtml">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
4 <head>
5 <title>Error - ${c.error_message}</title>
5 <title>Error - ${c.error_message}</title>
6 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
6 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
7 <meta name="robots" content="index, nofollow"/>
7 <meta name="robots" content="index, nofollow"/>
8
8
9 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
9 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
10 %if c.redirect_time:
10 %if c.redirect_time:
11 <meta http-equiv="refresh" content="${c.redirect_time}; url=${c.url_redirect}"/>
11 <meta http-equiv="refresh" content="${c.redirect_time}; url=${c.url_redirect}"/>
12 %endif
12 %endif
13
13
14 <link rel="icon" href="${h.asset('images/favicon.ico', ver=c.rhodecode_version_hash)}" sizes="16x16 32x32" type="image/png" />
14 <link rel="icon" href="${h.asset('images/favicon.ico', ver=c.rhodecode_version_hash)}" sizes="16x16 32x32" type="image/png" />
15 <script src="${h.asset('js/vendors/webcomponentsjs/custom-elements-es5-adapter.js', ver=c.rhodecode_version_hash)}"></script>
15 <script src="${h.asset('js/vendors/webcomponentsjs/custom-elements-es5-adapter.js', ver=c.rhodecode_version_hash)}"></script>
16 <script src="${h.asset('js/vendors/webcomponentsjs/webcomponents-bundle.js', ver=c.rhodecode_version_hash)}"></script>
16 <script src="${h.asset('js/vendors/webcomponentsjs/webcomponents-bundle.js', ver=c.rhodecode_version_hash)}"></script>
17
17
18 <link rel="stylesheet" type="text/css" href="${h.asset('css/style.css', ver=c.rhodecode_version_hash)}" media="screen"/>
18 <link rel="stylesheet" type="text/css" href="${h.asset('css/style.css', ver=c.rhodecode_version_hash)}" media="screen"/>
19 <style>body { background:#eeeeee; }</style>
19 <style>body { background:#eeeeee; }</style>
20 <script type="text/javascript">
20 <script type="text/javascript">
21 // register templateContext to pass template variables to JS
21 // register templateContext to pass template variables to JS
22 var templateContext = {timeago: {}};
22 var templateContext = {timeago: {}};
23 </script>
23 </script>
24 <script type="text/javascript" src="${h.asset('js/scripts.js', ver=c.rhodecode_version_hash)}"></script>
24 <script type="text/javascript" src="${h.asset('js/scripts.min.js', ver=c.rhodecode_version_hash)}"></script>
25 </head>
25 </head>
26 <body>
26 <body>
27
27
28 <div class="wrapper error_page">
28 <div class="wrapper error_page">
29 <div class="sidebar">
29 <div class="sidebar">
30 <a href="${h.route_path('home')}"><img class="error-page-logo" src="${h.asset('images/RhodeCode_Logo_Black.png')}" alt="RhodeCode"/></a>
30 <a href="${h.route_path('home')}"><img class="error-page-logo" src="${h.asset('images/RhodeCode_Logo_Black.png')}" alt="RhodeCode"/></a>
31 </div>
31 </div>
32 <div class="main-content">
32 <div class="main-content">
33 <h1>
33 <h1>
34 <span class="error-branding">
34 <span class="error-branding">
35 ${h.branding(c.rhodecode_name)}
35 ${h.branding(c.rhodecode_name)}
36 </span><br/>
36 </span><br/>
37 ${c.error_message}
37 ${c.error_message}
38 <br/>
38 <br/>
39 <span class="error_message">${c.error_explanation}</span>
39 <span class="error_message">${c.error_explanation}</span>
40 </h1>
40 </h1>
41 % if c.messages:
41 % if c.messages:
42 % for message in c.messages:
42 % for message in c.messages:
43 <div class="alert alert-${message.category}">${message}</div>
43 <div class="alert alert-${message.category}">${message}</div>
44 % endfor
44 % endfor
45 % endif
45 % endif
46 %if c.redirect_time:
46 %if c.redirect_time:
47 <p>${_('You will be redirected to %s in %s seconds') % (c.redirect_module,c.redirect_time)}</p>
47 <p>${_('You will be redirected to %s in %s seconds') % (c.redirect_module,c.redirect_time)}</p>
48 %endif
48 %endif
49 <div class="inner-column">
49 <div class="inner-column">
50 <h4>Possible Causes</h4>
50 <h4>Possible Causes</h4>
51 <ul>
51 <ul>
52 % if c.causes:
52 % if c.causes:
53 %for cause in c.causes:
53 %for cause in c.causes:
54 <li>${cause}</li>
54 <li>${cause}</li>
55 %endfor
55 %endfor
56 %else:
56 %else:
57 <li>The resource may have been deleted.</li>
57 <li>The resource may have been deleted.</li>
58 <li>You may not have access to this repository.</li>
58 <li>You may not have access to this repository.</li>
59 <li>The link may be incorrect.</li>
59 <li>The link may be incorrect.</li>
60 %endif
60 %endif
61 </ul>
61 </ul>
62 </div>
62 </div>
63 <div class="inner-column">
63 <div class="inner-column">
64 <h4>Support</h4>
64 <h4>Support</h4>
65 <p>For help and support, go to the <a href="${c.visual.rhodecode_support_url}" target="_blank">${_('Support Page')}</a>.
65 <p>For help and support, go to the <a href="${c.visual.rhodecode_support_url}" target="_blank">${_('Support Page')}</a>.
66 It may be useful to include your log file; see the log file locations <a href="${h.route_url('enterprise_log_file_locations')}">here</a>.
66 It may be useful to include your log file; see the log file locations <a href="${h.route_url('enterprise_log_file_locations')}">here</a>.
67 </p>
67 </p>
68
68
69 </div>
69 </div>
70 <div class="inner-column">
70 <div class="inner-column">
71 <h4>Documentation</h4>
71 <h4>Documentation</h4>
72 <p>For more information, see <a href="${h.route_url('enterprise_docs')}">docs.rhodecode.com</a>.</p>
72 <p>For more information, see <a href="${h.route_url('enterprise_docs')}">docs.rhodecode.com</a>.</p>
73 </div>
73 </div>
74 </div>
74 </div>
75
75
76 % if c.show_exception_id:
76 % if c.show_exception_id:
77 <div class="sidebar" style="width: 130px">
77 <div class="sidebar" style="width: 130px">
78
78
79 </div>
79 </div>
80 <div class="main-content">
80 <div class="main-content">
81 <p>
81 <p>
82 <strong>Exception ID: <code><a href="${c.exception_id_url}">${c.exception_id}</a></code> </strong> <br/>
82 <strong>Exception ID: <code><a href="${c.exception_id_url}">${c.exception_id}</a></code> </strong> <br/>
83
83
84 Super Admins can see detailed traceback information from this exception by checking the below Exception ID.<br/>
84 Super Admins can see detailed traceback information from this exception by checking the below Exception ID.<br/>
85 Please include the above link for further details of this exception.
85 Please include the above link for further details of this exception.
86 </p>
86 </p>
87 </div>
87 </div>
88 % endif
88 % endif
89 </div>
89 </div>
90
90
91 </body>
91 </body>
92
92
93 </html>
93 </html>
General Comments 0
You need to be logged in to leave comments. Login now