File: group_creation.t

package info (click to toggle)
adduser 3.154
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,584 kB
  • sloc: perl: 9,508; sh: 189; makefile: 22
file content (94 lines) | stat: -rwxr-xr-x 2,281 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#! /usr/bin/perl -Idebian/tests/lib

# check group_creation functionality

use diagnostics;
use strict;
use warnings;

use AdduserTestsCommon;

# how do I use a module from the package in question?
#use AddgroupRetvalues;

use constant RET_OK => 0;
use constant RET_OBJECT_EXISTS => 11;
use constant RET_WRONG_OBJECT_PROPERTIES => 13;

my $usergid=40000;
my $sysggid=400;
my $test_name="test1";
my $nextid;

my @quiet=("--stdoutmsglevel=error", '--stderrmsglevel=error');

# non-system group
$test_name="test1";
assert_command_success(
    '/usr/sbin/addgroup', @quiet,
    $test_name);
assert_group_exists($test_name);
assert_command_result_silent(RET_OBJECT_EXISTS,
    '/usr/sbin/addgroup', @quiet,
    $test_name);
assert_group_exists($test_name);

# non-system group
# with explicit --gid
$test_name="test1-a";
$usergid++;
assert_command_success(
    '/usr/sbin/addgroup', @quiet,
    '--gid', "$usergid",
    $test_name);
assert_group_gid_exists($test_name,$usergid);
assert_command_result_silent(RET_OBJECT_EXISTS,
    '/usr/sbin/addgroup', @quiet,
    '--gid', "$usergid",
    $test_name);
assert_group_gid_exists($test_name,$usergid);
$nextid=$usergid+1000;
assert_command_result_silent(RET_OBJECT_EXISTS,
    '/usr/sbin/addgroup', @quiet,
    '--gid', "$nextid",
    $test_name);
assert_group_gid_exists($test_name,$usergid);

# system group
$test_name="systest1";
assert_command_success(
    '/usr/sbin/addgroup', @quiet,
    '--system',
    $test_name);
assert_group_exists($test_name);
assert_command_success(
    '/usr/sbin/addgroup', @quiet,
    '--system',
    $test_name);
assert_group_exists($test_name);

# system group
# with explicit --gid
$test_name="systest1-a";
$sysggid++;
assert_command_success(
    '/usr/sbin/addgroup', @quiet,
    '--system',
    '--gid', "$sysggid",
    $test_name);
assert_group_gid_exists($test_name,$sysggid);
assert_command_success(
    '/usr/sbin/addgroup', @quiet,
    '--system',
    '--gid', "$sysggid",
    $test_name);
assert_group_gid_exists($test_name,$sysggid);
$nextid=$sysggid+1000;
assert_command_result_silent(RET_WRONG_OBJECT_PROPERTIES,
    '/usr/sbin/addgroup', @quiet,
    '--system',
    '--gid', "$nextid",
    $test_name);
assert_group_gid_exists($test_name,$sysggid);

# vim: tabstop=4 shiftwidth=4 expandtab