File: disable_test_cli_mgmt_static_site.py

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (198 lines) | stat: -rw-r--r-- 12,294 bytes parent folder | download
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# coding: utf-8

# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------

# Current Operation Coverage:
#   StaticSites: 12/26

import unittest

import azure.mgmt.web
from devtools_testutils import AzureMgmtTestCase, RandomNameResourceGroupPreparer

AZURE_LOCATION = "eastus2"


class MgmtWebSiteTest(AzureMgmtTestCase):

    def setUp(self):
        super(MgmtWebSiteTest, self).setUp()
        self.mgmt_client = self.create_mgmt_client(azure.mgmt.web.WebSiteManagementClient)

    @unittest.skip("skip temporarily")
    @RandomNameResourceGroupPreparer(location=AZURE_LOCATION)
    def test_static_site(self, resource_group):

        GITHUB_TOKEN = self.settings.GITHUB_TOKEN if self.is_live else "xxx"
        TENANT_ID = self.settings.TENANT_ID
        RESOURCE_GROUP = resource_group.name
        NAME = "myname"
        PR_ID = "1"
        DOMAIN_NAME = "mydomain"

        # --------------------------------------------------------------------------
        # /StaticSites/put/Create or update a static site[put]
        # --------------------------------------------------------------------------
        BODY = {
            "location": AZURE_LOCATION,
            "sku": {
                "name": "Free",
                #     "tier": "Free"
            },
            #   "repository_url": "https://github.com/username/RepoName",
            "repository_url": "https://github.com/00Kai0/html-docs-hello-world",
            "branch": "master",
            #   "repository_token": "repoToken123",
            "repository_token": GITHUB_TOKEN,
            "build_properties": {"app_location": "app", "api_location": "api", "app_artifact_location": "build"},
        }
        result = self.mgmt_client.static_sites.create_or_update_static_site(
            resource_group_name=RESOURCE_GROUP, name=NAME, static_site_envelope=BODY
        )

        # --------------------------------------------------------------------------
        # /StaticSites/put/Creates or updates the function app settings of a static site.[put]
        # --------------------------------------------------------------------------
        BODY = {"properties": {"setting1": "someval", "setting2": "someval2"}}
        # result = self.mgmt_client.static_sites.create_or_update_static_site_function_app_settings(resource_group_name=RESOURCE_GROUP, name=NAME, app_settings=BODY)

        # --------------------------------------------------------------------------
        # /StaticSites/put/Create or update a custom domain for a static site[put]
        # --------------------------------------------------------------------------
        # result = self.mgmt_client.static_sites.create_or_update_static_site_custom_domain(resource_group_name=RESOURCE_GROUP, name=NAME, domain_name=DOMAIN_NAME)

        # --------------------------------------------------------------------------
        # /StaticSites/put/Creates or updates the function app settings of a static site build.[put]
        # --------------------------------------------------------------------------
        BODY = {"setting1": "someval", "setting2": "someval2"}
        # result = self.mgmt_client.static_sites.create_or_update_static_site_build_function_app_settings(resource_group_name=RESOURCE_GROUP, name=NAME, pr_id=PR_ID, app_settings=BODY)

        # --------------------------------------------------------------------------
        # /StaticSites/get/Gets the functions of a particular static site build[get]
        # --------------------------------------------------------------------------
        result = self.mgmt_client.static_sites.list_static_site_build_functions(
            resource_group_name=RESOURCE_GROUP, name=NAME, pr_id=PR_ID
        )

        # --------------------------------------------------------------------------
        # /StaticSites/get/Get a static site build[get]
        # --------------------------------------------------------------------------
        # result = self.mgmt_client.static_sites.get_static_site_build(resource_group_name=RESOURCE_GROUP, name=NAME, pr_id=PR_ID)

        # --------------------------------------------------------------------------
        # /StaticSites/get/List custom domains for a static site[get]
        # --------------------------------------------------------------------------
        result = self.mgmt_client.static_sites.list_static_site_custom_domains(
            resource_group_name=RESOURCE_GROUP, name=NAME
        )

        # --------------------------------------------------------------------------
        # /StaticSites/get/Gets the functions of a static site[get]
        # --------------------------------------------------------------------------
        result = self.mgmt_client.static_sites.list_static_site_functions(resource_group_name=RESOURCE_GROUP, name=NAME)

        # --------------------------------------------------------------------------
        # /StaticSites/get/Get all builds for a static site[get]
        # --------------------------------------------------------------------------
        result = self.mgmt_client.static_sites.get_static_site_builds(resource_group_name=RESOURCE_GROUP, name=NAME)

        # --------------------------------------------------------------------------
        # /StaticSites/get/Get details for a static site[get]
        # --------------------------------------------------------------------------
        result = self.mgmt_client.static_sites.get_static_site(resource_group_name=RESOURCE_GROUP, name=NAME)

        # --------------------------------------------------------------------------
        # /StaticSites/get/Get static sites for a resource group[get]
        # --------------------------------------------------------------------------
        result = self.mgmt_client.static_sites.get_static_sites_by_resource_group(resource_group_name=RESOURCE_GROUP)

        # --------------------------------------------------------------------------
        # /StaticSites/get/Get all static sites in a subscription[get]
        # --------------------------------------------------------------------------
        result = self.mgmt_client.static_sites.list()

        # --------------------------------------------------------------------------
        # /StaticSites/patch/Create or update a user for a static site[patch]
        # --------------------------------------------------------------------------
        BODY = {"roles": "contributor"}
        # result = self.mgmt_client.static_sites.update_static_site_user(resource_group_name=RESOURCE_GROUP, name=NAME, authprovider=AUTHPROVIDER, userid=USERID, static_site_user_envelope=BODY)

        # --------------------------------------------------------------------------
        # /StaticSites/post/List users for a static site[post]
        # --------------------------------------------------------------------------
        # result = self.mgmt_client.static_sites.list_static_site_users(resource_group_name=RESOURCE_GROUP, name=NAME, authprovider=AUTHPROVIDER)

        # --------------------------------------------------------------------------
        # /StaticSites/post/Get function app settings of a static site build[post]
        # --------------------------------------------------------------------------
        # result = self.mgmt_client.static_sites.list_static_site_build_function_app_settings(resource_group_name=RESOURCE_GROUP, name=NAME, pr_id=PR_ID)

        # --------------------------------------------------------------------------
        # /StaticSites/post/Validate a custom domain for a static site[post]
        # --------------------------------------------------------------------------
        # result = self.mgmt_client.static_sites.validate_custom_domain_can_be_added_to_static_site(resource_group_name=RESOURCE_GROUP, name=NAME, domain_name=DOMAIN_NAME)

        # --------------------------------------------------------------------------
        # /StaticSites/post/Get function app settings of a static site[post]
        # --------------------------------------------------------------------------
        # result = self.mgmt_client.static_sites.list_static_site_function_app_settings(resource_group_name=RESOURCE_GROUP, name=NAME)

        # --------------------------------------------------------------------------
        # /StaticSites/post/Create an invitation link for a user for a static site[post]
        # --------------------------------------------------------------------------
        BODY = {
            "domain": "happy-sea-15afae3e.azurestaticwebsites.net",
            "provider": "aad",
            "user_details": "username",
            "roles": "admin,contributor",
            "num_hours_to_expiration": "1",
        }
        # result = self.mgmt_client.static_sites.create_user_roles_invitation_link(resource_group_name=RESOURCE_GROUP, name=NAME, static_site_user_roles_invitation_envelope=BODY)

        # --------------------------------------------------------------------------
        # /StaticSites/post/List secrets for a static site[post]
        # --------------------------------------------------------------------------
        result = self.mgmt_client.static_sites.list_static_site_secrets(resource_group_name=RESOURCE_GROUP, name=NAME)

        # --------------------------------------------------------------------------
        # /StaticSites/post/Reset the api key for a static site[post]
        # --------------------------------------------------------------------------
        BODY = {"should_update_repository": True, "repository_token": GITHUB_TOKEN}
        result = self.mgmt_client.static_sites.reset_static_site_api_key(
            resource_group_name=RESOURCE_GROUP, name=NAME, reset_properties_envelope=BODY
        )

        # --------------------------------------------------------------------------
        # /StaticSites/post/Detach a static site[post]
        # --------------------------------------------------------------------------
        result = self.mgmt_client.static_sites.detach_static_site(resource_group_name=RESOURCE_GROUP, name=NAME)

        # --------------------------------------------------------------------------
        # /StaticSites/patch/Patch a static site[patch]
        # --------------------------------------------------------------------------
        BODY = {}
        # result = self.mgmt_client.static_sites.update_static_site(resource_group_name=RESOURCE_GROUP, name=NAME, static_site_envelope=BODY)

        # --------------------------------------------------------------------------
        # /StaticSites/delete/Delete a user for a static site[delete]
        # --------------------------------------------------------------------------
        # result = self.mgmt_client.static_sites.delete_static_site_user(resource_group_name=RESOURCE_GROUP, name=NAME, authprovider=AUTHPROVIDER, userid=USERID)

        # --------------------------------------------------------------------------
        # /StaticSites/delete/Delete a custom domain for a static site[delete]
        # --------------------------------------------------------------------------
        # result = self.mgmt_client.static_sites.delete_static_site_custom_domain(resource_group_name=RESOURCE_GROUP, name=NAME, domain_name=DOMAIN_NAME)

        # --------------------------------------------------------------------------
        # /StaticSites/delete/Delete a static site build[delete]
        # --------------------------------------------------------------------------
        # result = self.mgmt_client.static_sites.delete_static_site_build(resource_group_name=RESOURCE_GROUP, name=NAME, pr_id=PR_ID)

        # --------------------------------------------------------------------------
        # /StaticSites/delete/Delete a static site[delete]
        # --------------------------------------------------------------------------
        result = self.mgmt_client.static_sites.delete_static_site(resource_group_name=RESOURCE_GROUP, name=NAME)