[Dev OpenGP] [118] added validation test |
[ Thread Index |
Date Index
| More opengp.tuxfamily.org/development Archives
]
Revision: 118
Author: nicolaf
Date: 2009-03-26 22:13:29 +0100 (Thu, 26 Mar 2009)
Log Message:
-----------
added validation test
Added Paths:
-----------
trunk/src/tests/validation/
trunk/src/tests/validation/ogpxmlconfig.xsd
trunk/src/tests/validation/validation.py
Added: trunk/src/tests/validation/ogpxmlconfig.xsd
===================================================================
--- trunk/src/tests/validation/ogpxmlconfig.xsd (rev 0)
+++ trunk/src/tests/validation/ogpxmlconfig.xsd 2009-03-26 21:13:29 UTC (rev 118)
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2009 by Nicolas FRANÇOIS
+ nicolaf@xxxxxxxxxxxxx
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the
+ Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ -->
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <!-- Root element -->
+ <xs:element name="ogp">
+ <xs:complexType>
+ <xs:sequence>
+ <!-- "plugin" elements : one entry for each plugin affecting the OU or machine
+ The "name" attribute specifies the plugin name. This attribute must be
+ unique among all the "plugin" elements.
+ -->
+ <xs:element name="plugin" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:all minOccurs="1" maxOccurs="1">
+ <xs:element name="files">
+ <xs:complexType>
+ <xs:sequence>
+ <!-- "file" elements : files affected by the plugin
+ The "name" attribute specifies a logical name (not necessary the "real" file name) to be used by the plugin.
+ This attribute must be unique among all the "file" elements.
+ -->
+ <xs:element name="file" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:all minOccurs="1" maxOccurs="1">
+ <!-- "security" element : standard unix security attributes + ACL. -->
+ <xs:element name="security">
+ <xs:complexType>
+ <xs:all minOccurs="0" maxOccurs="1">
+ <!-- User and group IDs. If not specified, inherited from the last parent OU which
+ specifies it or 0 (root) by default
+ -->
+ <xs:element name="uid" type="xs:nonNegativeInteger"/>
+ <xs:element name="gid" type="xs:nonNegativeInteger"/>
+ <!-- Standard Unix Permissions. If not specified, inherited from the last parent
+ conf which specifies it or 0644 by default.
+ See man chmod for more details.
+ -->
+ <xs:element name="us" type="xs:boolean"/>
+ <xs:element name="gs" type="xs:boolean"/>
+ <xs:element name="t" type="xs:boolean"/>
+ <xs:element name="ur" type="xs:boolean"/>
+ <xs:element name="uw" type="xs:boolean"/>
+ <xs:element name="ux" type="xs:boolean"/>
+ <xs:element name="gr" type="xs:boolean"/>
+ <xs:element name="gw" type="xs:boolean"/>
+ <xs:element name="gx" type="xs:boolean"/>
+ <xs:element name="or" type="xs:boolean"/>
+ <xs:element name="ow" type="xs:boolean"/>
+ <xs:element name="ox" type="xs:boolean"/>
+
+ <!-- ACL, as dumped by getfacl -->
+ <xs:element name="acl" minOccurs="0" maxOccurs="1">
+ <xs:complexType>
+ <xs:choice minOccurs="1" maxOccurs="unbounded">
+ <!-- One "ace" element for each access control entry.
+ The unique attribute "id" specifies the position in the list.
+ -->
+ <xs:element name="ace">
+ <xs:complexType>
+ <xs:attribute name="id" type="xs:nonNegativeInteger" use="required"/>
+ <xs:attribute name="value" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:choice>
+ </xs:complexType>
+ <!-- Unicity of the ace's id attribute -->
+ <xs:unique name="ace_id">
+ <xs:selector xpath="ace"/>
+ <xs:field xpath="@id"/>
+ </xs:unique>
+ </xs:element>
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="conf">
+ <xs:complexType mixed="true">
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:any processContents="skip"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:all>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <!-- Unicity of the file's name attribute -->
+ <xs:unique name="file_name">
+ <xs:selector xpath="file"/>
+ <xs:field xpath="@name"/>
+ </xs:unique>
+ </xs:element>
+ <xs:element name="conf">
+ <xs:complexType mixed="true">
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:any processContents="skip"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:all>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <!-- Unicity of the plugin's name attribute -->
+ <xs:unique name="plugin_name">
+ <xs:selector xpath="plugin"/>
+ <xs:field xpath="@name"/>
+ </xs:unique>
+ </xs:element>
+</xs:schema>
Added: trunk/src/tests/validation/validation.py
===================================================================
--- trunk/src/tests/validation/validation.py (rev 0)
+++ trunk/src/tests/validation/validation.py 2009-03-26 21:13:29 UTC (rev 118)
@@ -0,0 +1,14 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*
+
+from lxml.etree import *
+from ogp import etree
+from ogp.core import *
+core = OgpCore('ldap://localhost', 'cn=mac1,dc=nodomain', 'toto')
+
+schema_f = open('ogpxmlconfig.xsd')
+schema = etree.XMLSchema(parse(schema_f))
+
+tree=fromstring('<ogp><plugin name="motd"><conf><distro>debian</distro></conf><files><file name="motd"><conf>caca!</conf><security/></file><file name="motd.tail"><conf/><security/></file></files></plugin></ogp>', OGP_PARSER)
+
+print schema.validate(tree)
Property changes on: trunk/src/tests/validation/validation.py
___________________________________________________________________
Name: svn:executable
+ *