github.com/minio/console@v1.4.1/web-app/tests/utils/roles.ts (about)

     1  import { readFileSync } from "fs";
     2  import { Role, Selector } from "testcafe";
     3  
     4  const data = readFileSync(__dirname + "/../constants/timestamp.txt", "utf-8");
     5  const unixTimestamp = data.trim();
     6  
     7  const loginUrl = "http://localhost:9090/login";
     8  // diagnostics/watch/trace need to run in port 9090 (through the server) to work
     9  const loginUrlServer = "http://localhost:9090/login";
    10  const submitButton = Selector("button").withAttribute("id", "do-login");
    11  
    12  export const admin = Role(
    13    loginUrl,
    14    async (t) => {
    15      await t
    16        .typeText("#accessKey", "minioadmin")
    17        .typeText("#secretKey", "minioadmin")
    18        .click(submitButton);
    19    },
    20    { preserveUrl: true },
    21  );
    22  
    23  export const bucketAssignPolicy = Role(
    24    loginUrl,
    25    async (t) => {
    26      await t
    27        .typeText("#accessKey", "bucketassignpolicy-" + unixTimestamp)
    28        .typeText("#secretKey", "bucketassignpolicy")
    29        .click(submitButton);
    30    },
    31    { preserveUrl: true },
    32  );
    33  
    34  export const bucketRead = Role(
    35    loginUrl,
    36    async (t) => {
    37      await t
    38        .typeText("#accessKey", "bucketread-" + unixTimestamp)
    39        .typeText("#secretKey", "bucketread")
    40        .click(submitButton);
    41    },
    42    { preserveUrl: true },
    43  );
    44  
    45  export const bucketWrite = Role(
    46    loginUrl,
    47    async (t) => {
    48      await t
    49        .typeText("#accessKey", "bucketwrite-" + unixTimestamp)
    50        .typeText("#secretKey", "bucketwrite")
    51        .click(submitButton);
    52    },
    53    { preserveUrl: true },
    54  );
    55  
    56  export const bucketReadWrite = Role(
    57    loginUrl,
    58    async (t) => {
    59      await t
    60        .typeText("#accessKey", "bucketreadwrite-" + unixTimestamp)
    61        .typeText("#secretKey", "bucketreadwrite")
    62        .click(submitButton);
    63    },
    64    { preserveUrl: true },
    65  );
    66  
    67  export const bucketObjectTags = Role(
    68    loginUrl,
    69    async (t) => {
    70      await t
    71        .typeText("#accessKey", "bucketobjecttags-" + unixTimestamp)
    72        .typeText("#secretKey", "bucketobjecttags")
    73        .click(submitButton);
    74    },
    75    { preserveUrl: true },
    76  );
    77  
    78  export const bucketCannotTag = Role(
    79    loginUrl,
    80    async (t) => {
    81      await t
    82        .typeText("#accessKey", "bucketcannottag-" + unixTimestamp)
    83        .typeText("#secretKey", "bucketcannottag")
    84        .click(submitButton);
    85    },
    86    { preserveUrl: true },
    87  );
    88  
    89  export const bucketSpecific = Role(
    90    loginUrl,
    91    async (t) => {
    92      await t
    93        .typeText("#accessKey", "bucketspecific-" + unixTimestamp)
    94        .typeText("#secretKey", "bucketspecific")
    95        .click(submitButton);
    96    },
    97    { preserveUrl: true },
    98  );
    99  
   100  export const bucketWritePrefixOnly = Role(
   101    loginUrl,
   102    async (t) => {
   103      await t
   104        .typeText("#accessKey", "bucketwriteprefixonlypolicy-" + unixTimestamp)
   105        .typeText("#secretKey", "bucketwriteprefixonlypolicy")
   106        .click(submitButton);
   107    },
   108    { preserveUrl: true },
   109  );
   110  
   111  export const dashboard = Role(
   112    loginUrl,
   113    async (t) => {
   114      await t
   115        .typeText("#accessKey", "dashboard-" + unixTimestamp)
   116        .typeText("#secretKey", "dashboard")
   117        .click(submitButton);
   118    },
   119    { preserveUrl: true },
   120  );
   121  
   122  export const diagnostics = Role(
   123    loginUrlServer,
   124    async (t) => {
   125      await t
   126        .typeText("#accessKey", "diagnostics-" + unixTimestamp)
   127        .typeText("#secretKey", "diagnostics")
   128        .click(submitButton);
   129    },
   130    { preserveUrl: true },
   131  );
   132  
   133  export const groups = Role(
   134    loginUrl,
   135    async (t) => {
   136      await t
   137        .typeText("#accessKey", "groups-" + unixTimestamp)
   138        .typeText("#secretKey", "groups1234")
   139        .click(submitButton);
   140    },
   141    { preserveUrl: true },
   142  );
   143  
   144  export const heal = Role(
   145    loginUrlServer,
   146    async (t) => {
   147      await t
   148        .typeText("#accessKey", "heal-" + unixTimestamp)
   149        .typeText("#secretKey", "heal1234")
   150        .click(submitButton);
   151    },
   152    { preserveUrl: true },
   153  );
   154  
   155  export const iamPolicies = Role(
   156    loginUrl,
   157    async (t) => {
   158      await t
   159        .typeText("#accessKey", "iampolicies-" + unixTimestamp)
   160        .typeText("#secretKey", "iampolicies")
   161        .click(submitButton);
   162    },
   163    { preserveUrl: true },
   164  );
   165  
   166  export const logs = Role(
   167    loginUrl,
   168    async (t) => {
   169      await t
   170        .typeText("#accessKey", "logs-" + unixTimestamp)
   171        .typeText("#secretKey", "logs1234")
   172        .click(submitButton);
   173    },
   174    { preserveUrl: true },
   175  );
   176  
   177  export const notificationEndpoints = Role(
   178    loginUrl,
   179    async (t) => {
   180      await t
   181        .typeText("#accessKey", "notificationendpoints-" + unixTimestamp)
   182        .typeText("#secretKey", "notificationendpoints")
   183        .click(submitButton);
   184    },
   185    { preserveUrl: true },
   186  );
   187  
   188  export const settings = Role(
   189    loginUrl,
   190    async (t) => {
   191      await t
   192        .typeText("#accessKey", "settings-" + unixTimestamp)
   193        .typeText("#secretKey", "settings")
   194        .click(submitButton);
   195    },
   196    { preserveUrl: true },
   197  );
   198  
   199  export const tiers = Role(
   200    loginUrl,
   201    async (t) => {
   202      await t
   203        .typeText("#accessKey", "tiers-" + unixTimestamp)
   204        .typeText("#secretKey", "tiers1234")
   205        .click(submitButton);
   206    },
   207    { preserveUrl: true },
   208  );
   209  
   210  export const trace = Role(
   211    loginUrlServer,
   212    async (t) => {
   213      await t
   214        .typeText("#accessKey", "trace-" + unixTimestamp)
   215        .typeText("#secretKey", "trace1234")
   216        .click(submitButton);
   217    },
   218    { preserveUrl: true },
   219  );
   220  
   221  export const users = Role(
   222    loginUrl,
   223    async (t) => {
   224      await t
   225        .typeText("#accessKey", "users-" + unixTimestamp)
   226        .typeText("#secretKey", "users1234")
   227        .click(submitButton);
   228    },
   229    { preserveUrl: true },
   230  );
   231  
   232  export const watch = Role(
   233    loginUrlServer,
   234    async (t) => {
   235      await t
   236        .typeText("#accessKey", "watch-" + unixTimestamp)
   237        .typeText("#secretKey", "watch1234")
   238        .click(submitButton);
   239    },
   240    { preserveUrl: true },
   241  );
   242  
   243  export const deleteObjectWithPrefixOnly = Role(
   244    loginUrl,
   245    async (t) => {
   246      await t
   247        .typeText("#accessKey", "delete-object-with-prefix-" + unixTimestamp)
   248        .typeText("#secretKey", "deleteobjectwithprefix1234")
   249        .click(submitButton);
   250    },
   251    { preserveUrl: true },
   252  );
   253  
   254  export const conditions1 = Role(
   255    loginUrl,
   256    async (t) => {
   257      await t
   258        .typeText("#accessKey", "conditions-" + unixTimestamp)
   259        .typeText("#secretKey", "conditions1234")
   260        .click(submitButton);
   261    },
   262    { preserveUrl: true },
   263  );
   264  
   265  export const conditions2 = Role(
   266    loginUrl,
   267    async (t) => {
   268      await t
   269        .typeText("#accessKey", "conditions-2-" + unixTimestamp)
   270        .typeText("#secretKey", "conditions1234")
   271        .click(submitButton);
   272    },
   273    { preserveUrl: true },
   274  );
   275  
   276  export const conditions3 = Role(
   277    loginUrl,
   278    async (t) => {
   279      await t
   280        .typeText("#accessKey", "conditions-3-" + unixTimestamp)
   281        .typeText("#secretKey", "conditions1234")
   282        .click(submitButton);
   283    },
   284    { preserveUrl: true },
   285  );
   286  
   287  export const conditions4 = Role(
   288    loginUrl,
   289    async (t) => {
   290      await t
   291        .typeText("#accessKey", "conditions-4-" + unixTimestamp)
   292        .typeText("#secretKey", "conditions1234")
   293        .click(submitButton);
   294    },
   295    { preserveUrl: true },
   296  );
   297  
   298  export const rewindEnabled = Role(
   299    loginUrl,
   300    async (t) => {
   301      await t
   302        .typeText("#accessKey", "rewind-allowed-" + unixTimestamp)
   303        .typeText("#secretKey", "rewindallowed1234")
   304        .click(submitButton);
   305    },
   306    { preserveUrl: true },
   307  );
   308  
   309  export const rewindNotEnabled = Role(
   310    loginUrl,
   311    async (t) => {
   312      await t
   313        .typeText("#accessKey", "rewind-not-allowed-" + unixTimestamp)
   314        .typeText("#secretKey", "rewindnotallowed1234")
   315        .click(submitButton);
   316    },
   317    { preserveUrl: true },
   318  );