environments/ppa-mbqj77/deployments/1
Xavier Guimard 10 years ago
parent 4bff7a6423
commit 1c93769e1b
  1. 5
      e2e-tests/manager/01-tree.js
  2. 7
      lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI.pm
  3. 14
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf.pm

@ -12,7 +12,7 @@ describe('Lemonldap::NG Manager', function() {
expect(mainNodes.count()).toEqual(9);
});
it('should find a default rule', function() {
it('should find a rule', function() {
browser.get('/#/confs/1');
var vhs = element(by.id('a-virtualHosts'));
vhs.click();
@ -22,7 +22,6 @@ describe('Lemonldap::NG Manager', function() {
r.click();
var def = element.all(by.id("t-virtualHosts/manager.example.com/locationRules/1"));
expect(def.count()).toEqual(1);
expect(def.get(0).getText()).toEqual('default');
});
it('should find 19 auth/user modules but only Demo visible', function() {
browser.get('/#/confs/1');
@ -38,4 +37,4 @@ describe('Lemonldap::NG Manager', function() {
expect(def.count()).toEqual(1);
});
});
});
});

@ -99,11 +99,12 @@ sub userError {
sub sendJSONresponse {
my ( $self, $req, $j, %args ) = @_;
$args{code} ||= 200;
$args{headers} ||= [];
my $type = 'application/json; charset=utf-8';
if ( ref $j ) {
$j = $_json->encode($j);
}
return [ $args{code}, [ 'Content-Type', $type ], [$j] ];
return [ $args{code}, [ 'Content-Type' => $type, @{$args{headers}} ], [$j] ];
}
sub sendError {
@ -329,7 +330,7 @@ The response is always send with a 200 code.
Stringify $json object and send it to the client. $req is the
Lemonldap::NG::Common::PSGI::Request object; %args can define the HTTP error
code (200 by default).
code (200 by default) or headers to add.
If client is not json compatible (`Accept` header), response is send in XML.
@ -339,6 +340,8 @@ Examples:
$self->sendJSONresponse ( $req, { result => 1 } );
$self->sendJSONresponse ( $req, { result => 1 }, headers => [ X => Z ] );
=head3 sendError ( $req, $msg, $code )
Call sendJSONresponse with `{ error => $msg }` and code (default to 500) and

@ -651,9 +651,15 @@ sub metadatas {
'User '
. $self->userId($req)
. ' ask for full configuration '
. $c->{cfgNum} );
return $self->sendJSONresponse( $req, $self->currentConf,
forceJSON => 1 );
. $c );
return $self->sendJSONresponse(
$req,
$self->currentConf,
forceJSON => 1,
headers => [
'Content-Disposition' => "Attachment; filename=lmConf-$c.json"
],
);
}
else {
my $res = {};
@ -863,7 +869,7 @@ sub newConf {
# If ref conf isn't last conf, consider conf changed
my $cfgNum = $self->confAcc->lastCfg;
unless(defined $cfgNum) {
unless ( defined $cfgNum ) {
$req->error($Lemonldap::NG::Common::Conf::msg);
}
return $self->sendError( $req, undef, 400 ) if ( $req->error );

Loading…
Cancel
Save